Package com.tccc.kos.core.service.spawn
Class SpawnProcess
java.lang.Object
com.tccc.kos.core.service.spawn.SpawnProcess
- Direct Known Subclasses:
Adapter
Class that represents a single process that can be spawned.
- Since:
- 1.0
- Version:
- 2022-09-12
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a command line argument.getArgs()
getGroup()
Return the group that the program should be run as.getPath()
int
getPid()
int
getUser()
Return the user that the program should be run as.Set the group that the program should be run as.setLogFile
(String logFile) Redirect stdout/stderr to the specified file name in the/mnt/logs
directory.Set the path to the executable.Set the path to the executable.void
setPriority
(int priority) Set the priority of the process.Set the user (and group) that the program should be run as.setWorkingDir
(File dir) Set the working directory.setWorkingDir
(String path) Set the working directory.toString()
boolean
waitForStart
(long timeout) Wait for the process to start.
-
Field Details
-
MAX_PATH_LEN
public static final int MAX_PATH_LEN- See Also:
-
MAX_ARG_LEN
public static final int MAX_ARG_LEN- See Also:
-
MAX_ARGS
public static final int MAX_ARGS- See Also:
-
MAX_USER_GROUP_LEN
public static final int MAX_USER_GROUP_LEN- See Also:
-
MIN_PRIORITY
public static final int MIN_PRIORITY- See Also:
-
MAX_PRIORITY
public static final int MAX_PRIORITY- See Also:
-
-
Constructor Details
-
SpawnProcess
public SpawnProcess()
-
-
Method Details
-
setPath
Set the path to the executable.- Parameters:
file
- the path to the executable
-
setPath
Set the path to the executable.- Parameters:
path
- path to the executable
-
setWorkingDir
Set the working directory.- Parameters:
dir
- the working directory
-
setWorkingDir
Set the working directory.- Parameters:
path
- path to the working directory
-
setLogFile
Redirect stdout/stderr to the specified file name in the/mnt/logs
directory. The file must be a valid filename. If a path is specified, it will be stripped off and only the final filename will be used. When set, this file will be created in the log directory and will be subject to standard log processing processes.- Parameters:
logFile
- the name of the log file
-
getUser
Return the user that the program should be run as.- Returns:
- the desired user for the program
-
setUser
Set the user (and group) that the program should be run as. This will lookup the specified user and switch to the associated uid and default gid for the user. If this user doesn't exist, the program will fail to spawn. Leave unset or set to null to run as the same user as the adapter (typically root).- Parameters:
user
- the user used to run the program
-
getGroup
Return the group that the program should be run as.- Returns:
- the desired group for the program
-
setGroup
Set the group that the program should be run as. If setUser() was called, this will already set the group to the default group for the user. Use this to switch the user to another non-default group. If the group doesn't exist, the program will fail to spawn.- Parameters:
group
- the group used to run the program
-
addArg
Add a command line argument.- Parameters:
arg
- the argument to add
-
setPriority
public void setPriority(int priority) Set the priority of the process. This can only be called until the process is created. After this you must use SpawnService.setPriority().- Parameters:
priority
- the priority of the process -20..19 (unix semantics)
-
waitForStart
public boolean waitForStart(long timeout) Wait for the process to start.- Parameters:
timeout
- how long to wait- Returns:
- true if started
-
toString
-
getNodeId
-
getPath
-
getWorkingDir
-
getArgs
-
getLogFile
-
getPid
public int getPid() -
getPriority
public int getPriority()
-