Package com.atlassian.bamboo.process
Class ProcessManagement
java.lang.Object
com.atlassian.bamboo.process.ProcessManagement
- Direct Known Subclasses:
UnixProcessManagement
,WindowsProcessManagement
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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) getPids()
abstract String
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
void
sleep
(long milliseconds)
-
Field Details
-
log
protected static final org.apache.logging.log4j.Logger log
-
-
Constructor Details
-
ProcessManagement
protected ProcessManagement()
-
-
Method Details
-
getInstance
- Throws:
Exception
-
getPsDetectionCommand
-
isWindows
public static boolean isWindows() -
isMac
public static boolean isMac() -
isUnix
public static boolean isUnix() -
generateStackTrace
-
getGentleKillCmd
-
getRudeKillCmd
-
getStackTraceAndKillRelatedProcesses
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
-
sleep
- Throws:
Exception
-
buildLog
-
executeCommand
Need to capture the output of some process, e.g. jstack.- Parameters:
command
- to be executedreadOutput
-
-
getRelatedProcesses
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:
-
getPids
-