Jump to content

Dealing with crashed OSBot processes in a bot farm


PlumpRump

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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