Jump to content

Dealing with crashed OSBot processes in a bot farm


Recommended Posts

Posted

I've been experimenting with running a farm on a local computer I own and on a VPS. I've run into the issue of OSBot clients sometimes either freezing or malfunctioning due to proxy unreliability. These clients will stay open, hogging up memory and causing functioning clients to run out of memory. I currently need to manually find the broken clients and close them. For a small farm this may be somewhat feasible, but will definitely not work if I want to scale up. Does anyone know a good way to automatically close the malfunctioning OSBot clients?

Posted
public static void killByEmail(String email) {
        ProcessBuilder findPIDs = new ProcessBuilder("/bin/sh", "-c", "ps -ef | grep '" + email + "' | awk '{print $2}'");
        try {
            Process findPIDsProcess = findPIDs.start();
            BufferedReader in = new BufferedReader(new InputStreamReader(findPIDsProcess.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println("Attempting to kill process " + line);
                ProcessBuilder killPID = new ProcessBuilder("kill", "-9", line);
                killPID.start();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

I came up with this solution, but I haven't tested it in the farm yet, just manually tested. It searches all the system's processes, finds the ones that were started with the given email, and extracts the PID for each. Then it iterates through all the processes it found and kills them. I have a way of telling if the bots are dead or not, so it's trivial to call this method whenever my system detects a bot died or failed to start.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...