public abstract class ProcessManagement extends Object
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
log |
Modifier | Constructor and Description |
---|---|
protected |
ProcessManagement() |
Modifier and Type | Method and 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#SEC26
|
abstract String |
getRudeKillCmd(String pid) |
void |
getStackTraceAndKillRelatedProcesses(int pid)
Entry point method for this class in the HBK plugin
|
static boolean |
isMac() |
static boolean |
isUnix() |
static boolean |
isWindows() |
void |
sleep(long milliseconds) |
public static ProcessManagement getInstance(BuildLogger buildLogger) throws Exception
Exception
public abstract String getPsDetectionCommand()
public static boolean isWindows()
public static boolean isMac()
public static boolean isUnix()
public abstract void generateStackTrace(int pid, String command)
public void getStackTraceAndKillRelatedProcesses(int pid) throws Exception
This 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.
pid
- Usually the bamboo's agent pid.Exception
public void executeCommand(String command, boolean readOutput)
command
- to be executedreadOutput
- public Set<Map<String,String>> getRelatedProcesses(int pid, Map<Integer,Map<String,String>> pids)
pid
- pids
- Copyright © 2019 Atlassian Software Systems Pty Ltd. All rights reserved.