PlumpRump Posted July 1, 2019 Share Posted July 1, 2019 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? Quote Link to comment Share on other sites More sharing options...
PlumpRump Posted July 2, 2019 Author Share Posted July 2, 2019 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. Quote Link to comment Share on other sites More sharing options...