Class SpawnProcess

java.lang.Object
com.tccc.kos.core.service.spawn.SpawnProcess
Direct Known Subclasses:
Adapter

public class SpawnProcess extends Object
Class that represents a single process that can be spawned.
Since:
1.0
Version:
2022-09-12
  • Field Details

  • Constructor Details

    • SpawnProcess

      public SpawnProcess()
  • Method Details

    • setPath

      public SpawnProcess setPath(File file)
      Set the path to the executable.
      Parameters:
      file - the path to the executable
    • setPath

      public SpawnProcess setPath(String path)
      Set the path to the executable.
      Parameters:
      path - path to the executable
    • setWorkingDir

      public SpawnProcess setWorkingDir(File dir)
      Set the working directory.
      Parameters:
      dir - the working directory
    • setWorkingDir

      public SpawnProcess setWorkingDir(String path)
      Set the working directory.
      Parameters:
      path - path to the working directory
    • setLogFile

      public SpawnProcess setLogFile(String logFile)
      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

      public String getUser()
      Return the user that the program should be run as.
      Returns:
      the desired user for the program
    • setUser

      public SpawnProcess setUser(String user)
      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

      public String getGroup()
      Return the group that the program should be run as.
      Returns:
      the desired group for the program
    • setGroup

      public SpawnProcess setGroup(String group)
      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

      public SpawnProcess addArg(Object arg)
      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

      public String toString()
      Overrides:
      toString in class Object
    • getNodeId

      public NodeId getNodeId()
    • getPath

      public String getPath()
    • getWorkingDir

      public String getWorkingDir()
    • getArgs

      public List<String> getArgs()
    • getLogFile

      public String getLogFile()
    • getPid

      public int getPid()
    • getPriority

      public int getPriority()