Package com.atlassian.bamboo.process
Class ProcessManagement
- java.lang.Object
-
- com.atlassian.bamboo.process.ProcessManagement
-
- Direct Known Subclasses:
UnixProcessManagement,WindowsProcessManagement
public abstract class ProcessManagement extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.log4j.Loggerlog
-
Constructor Summary
Constructors Modifier Constructor Description protectedProcessManagement()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringbuildLog(String message, boolean isError)voidexecuteCommand(String command, boolean readOutput)Need to capture the output of some process, e.g.abstract voidgenerateStackTrace(int pid, String command)abstract StringgetGentleKillCmd(String pid)static ProcessManagementgetInstance(BuildLogger buildLogger)Map<Integer,Map<String,String>>getPids()abstract StringgetPsDetectionCommand()Set<Map<String,String>>getRelatedProcesses(int pid, Map<Integer,Map<String,String>> pids)get all descendants from 'pid' We are also interested in orphans processes related to our pid so we also need to filter children of 1 (orphan process) with the same process group id groups id's are the only reliable way of getting related processes http://www.steve.org.uk/Reference/Unix/faq_2.html#SEC26abstract StringgetRudeKillCmd(String pid)voidgetStackTraceAndKillRelatedProcesses(int pid)Entry point method for this class in the HBK pluginstatic booleanisMac()static booleanisUnix()static booleanisWindows()voidsleep(long milliseconds)
-
-
-
Method Detail
-
getInstance
public static ProcessManagement getInstance(BuildLogger buildLogger) throws Exception
- Throws:
Exception
-
getPsDetectionCommand
public abstract String getPsDetectionCommand()
-
isWindows
public static boolean isWindows()
-
isMac
public static boolean isMac()
-
isUnix
public static boolean isUnix()
-
generateStackTrace
public abstract void generateStackTrace(int pid, String command)
-
getStackTraceAndKillRelatedProcesses
public void getStackTraceAndKillRelatedProcesses(int pid) throws ExceptionEntry point method for this class in the HBK pluginThis method will get a stack trace and kill the subprocesses (and orphans) related to the process with 'pid' id. In Bamboo build that will effectively stop a build and collect valuable information.
- Parameters:
pid- Usually the bamboo's agent pid.- Throws:
Exception
-
executeCommand
public void executeCommand(String command, boolean readOutput)
Need to capture the output of some process, e.g. jstack.- Parameters:
command- to be executedreadOutput-
-
getRelatedProcesses
public Set<Map<String,String>> getRelatedProcesses(int pid, Map<Integer,Map<String,String>> pids)
get all descendants from 'pid' We are also interested in orphans processes related to our pid so we also need to filter children of 1 (orphan process) with the same process group id groups id's are the only reliable way of getting related processes http://www.steve.org.uk/Reference/Unix/faq_2.html#SEC26- Parameters:
pid-pids-- Returns:
-
-