class ProcessLauncherInterface¶
Overview¶
Functions for all process launchers. More…
#include <process_launcher.h> class ProcessLauncherInterface: public PtrTemplates { public: // typedefs typedef LaunchCommandInterface::ENGINE_RUNNING_STATUS ENGINE_RUNNING_STATUS; // fields 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; // methods virtual std::string launcherName() const = 0; virtual ProcessLauncherInterface::unique_ptr createLauncher(int logFD = -1) = 0; virtual pid_t launchProcess( nlohmann::json procConfig, bool appendParentEnv = true ) = 0; virtual pid_t stopProcess(unsigned int killWait) = 0; virtual ENGINE_RUNNING_STATUS getProcessStatus(); LaunchCommandInterface* launchCommand() const; void setFileDescriptor(int logFD); }; // direct descendants template < class PROCESS_LAUNCHER, const char* LAUNCHER_TYPE, class ... LAUNCHER_COMMANDS > class ProcessLauncher;
Inherited Members¶
public: // typedefs typedef std::shared_ptr<T> shared_ptr; typedef std::shared_ptr<const T> const_shared_ptr; typedef std::unique_ptr<T> unique_ptr; typedef std::unique_ptr<const T> const_unique_ptr;
Detailed Documentation¶
Functions for all process launchers.
Methods¶
virtual std::string launcherName() const = 0
Get name of launcher.
virtual ProcessLauncherInterface::unique_ptr createLauncher(int logFD = -1) = 0
Create a new process launcher.
Parameters:
logFD |
File descriptor to route stdout and stderror outputs in launched process |
virtual pid_t launchProcess( nlohmann::json procConfig, bool appendParentEnv = true ) = 0
Fork a new process. Will read environment variables and start params from procConfig.
Parameters:
procConfig |
Process Configuration. Env variables and start params take precedence over envParams and startParams |
appendParentEnv |
Should parent env variables be appended to child process |
Returns:
Returns Process ID of child process on success
virtual pid_t stopProcess(unsigned int killWait) = 0
Stop a running process.
Parameters:
killWait |
Time (in seconds) to wait for process to quit by itself before force killing it. 0 means it will wait indefinitely |
Returns:
Returns child PID on success, negative value on error
virtual ENGINE_RUNNING_STATUS getProcessStatus()
Get the current process status. If status cannot be retrieved, return ENGINE_RUNNING_STATUS::UNKNOWN.
Returns:
Returns status as enum ProcessLauncherInterface::ENGINE_RUNNING_STATUS
LaunchCommandInterface* launchCommand() const
Get Launch Command. If launchProcess has not yet been called, return nullptr.
void setFileDescriptor(int logFD)
Sets the file descriptor that will be used by the launched process to write stdout and stderror.
Parameters:
logFD |
File descriptor to route stdout and stderror outputs in launched process |