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.Logger
log
-
Constructor Summary
Constructors Modifier Constructor Description protected
ProcessManagement()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
buildLog(String message, boolean isError)
void
executeCommand(String command, boolean readOutput)
Need to capture the output of some process, e.g.abstract void
generateStackTrace(int pid, String command)
abstract String
getGentleKillCmd(String pid)
static ProcessManagement
getInstance(BuildLogger buildLogger)
Map<Integer,Map<String,String>>
getPids()
abstract String
getPsDetectionCommand()
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 String
getRudeKillCmd(String pid)
void
getStackTraceAndKillRelatedProcesses(int pid)
Entry point method for this class in the HBK pluginstatic boolean
isMac()
static boolean
isUnix()
static boolean
isWindows()
void
sleep(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 Exception
Entry 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:
-
-