Functions for all process launchers. More...
#include <process_launcher.h>
Public Types | |
| using | ENGINE_RUNNING_STATUS = LaunchCommandInterface::ENGINE_RUNNING_STATUS |
Public Types inherited from PtrTemplates< ProcessLauncherInterface > | |
| using | shared_ptr = std::shared_ptr< ProcessLauncherInterface > |
| using | const_shared_ptr = std::shared_ptr< const ProcessLauncherInterface > |
| using | unique_ptr = std::unique_ptr< ProcessLauncherInterface > |
| using | const_unique_ptr = std::unique_ptr< const ProcessLauncherInterface > |
Public Member Functions | |
| virtual | ~ProcessLauncherInterface ()=default |
| virtual std::string | launcherName () const =0 |
| Get name of launcher. More... | |
| virtual ProcessLauncherInterface::unique_ptr | createLauncher (int logFD=-1)=0 |
| Create a new process launcher. More... | |
| virtual pid_t | launchProcess (nlohmann::json procConfig, bool appendParentEnv=true)=0 |
| Fork a new process. Will read environment variables and start params from procConfig. More... | |
| virtual pid_t | stopProcess (unsigned int killWait)=0 |
| Stop a running process. More... | |
| virtual ENGINE_RUNNING_STATUS | getProcessStatus () |
| Get the current process status. If status cannot be retrieved, return ENGINE_RUNNING_STATUS::UNKNOWN. More... | |
| LaunchCommandInterface * | launchCommand () const |
| Get Launch Command. If launchProcess has not yet been called, return nullptr. More... | |
| void | setFileDescriptor (int logFD) |
| Sets the file descriptor that will be used by the launched process to write stdout and stderror. More... | |
Static Public Attributes | |
| static constexpr auto | UNKNOWN = LaunchCommandInterface::ENGINE_RUNNING_STATUS::UNKNOWN |
| static constexpr auto | RUNNING = LaunchCommandInterface::ENGINE_RUNNING_STATUS::RUNNING |
| static constexpr auto | STOPPED = LaunchCommandInterface::ENGINE_RUNNING_STATUS::STOPPED |
Static Protected Member Functions | |
| static bool | checkEnvVar (const std::string &envVar) |
| Checks given Environment variable for correctness (Should contain an '=' character) More... | |
| static std::tuple< std::string, std::string > | splitEnvVar (const std::string &envVar) |
| Split Environment variable string into variable name and value. More... | |
Protected Attributes | |
| LaunchCommandInterface::unique_ptr | _launchCmd = nullptr |
| Launch Command. More... | |
| int | _logFD = -1 |
| File descriptor to route stdout and stderror outputs in launched process. More... | |
Functions for all process launchers.
| using ProcessLauncherInterface::ENGINE_RUNNING_STATUS = LaunchCommandInterface::ENGINE_RUNNING_STATUS |
|
virtualdefault |
|
staticprotected |
Checks given Environment variable for correctness (Should contain an '=' character)
| envVar | Variable to check |
|
pure virtual |
Create a new process launcher.
| logFD | File descriptor to route stdout and stderror outputs in launched process |
Implemented in ProcessLauncher< PROCESS_LAUNCHER, LAUNCHER_TYPE, LAUNCHER_COMMANDS >, and ProcessLauncher< ProcessLauncherBasic, Basic, BasicFork, DockerLauncher, EmptyLaunchCommand >.
|
inlinevirtual |
Get the current process status. If status cannot be retrieved, return ENGINE_RUNNING_STATUS::UNKNOWN.
| LaunchCommandInterface * ProcessLauncherInterface::launchCommand | ( | ) | const |
Get Launch Command. If launchProcess has not yet been called, return nullptr.
|
pure virtual |
Get name of launcher.
Implemented in ProcessLauncher< PROCESS_LAUNCHER, LAUNCHER_TYPE, LAUNCHER_COMMANDS >.
|
pure virtual |
Fork a new process. Will read environment variables and start params from procConfig.
| procConfig | Process Configuration. Env variables and start params take precedence over envParams and startParams |
| appendParentEnv | Should parent env variables be appended to child process |
Implemented in ProcessLauncher< PROCESS_LAUNCHER, LAUNCHER_TYPE, LAUNCHER_COMMANDS >, and ProcessLauncher< ProcessLauncherBasic, Basic, BasicFork, DockerLauncher, EmptyLaunchCommand >.
| void ProcessLauncherInterface::setFileDescriptor | ( | int | logFD | ) |
Sets the file descriptor that will be used by the launched process to write stdout and stderror.
| logFD | File descriptor to route stdout and stderror outputs in launched process |
|
staticprotected |
Split Environment variable string into variable name and value.
| envVar | String to split. Should have the form <VAR_NAME>=<VAR_VALUE> |
|
pure virtual |
Stop a running process.
| killWait | Time (in seconds) to wait for process to quit by itself before force killing it. 0 means it will wait indefinitely |
Implemented in ProcessLauncher< PROCESS_LAUNCHER, LAUNCHER_TYPE, LAUNCHER_COMMANDS >, and ProcessLauncher< ProcessLauncherBasic, Basic, BasicFork, DockerLauncher, EmptyLaunchCommand >.
|
protected |
Launch Command.
|
protected |
File descriptor to route stdout and stderror outputs in launched process.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |