class BasicFork

Overview

#include <basic_fork.h>

class BasicFork: public LaunchCommand {
public:
    // methods

    virtual pid_t launchProcess(
        const nlohmann::json& launcherConfig,
        const std::string& procCmd,
        const std::vector<std::string>& envParams,
        const std::vector<std::string>& startParams,
        bool appendParentEnv = true,
        int logFD = -1
    );

    virtual pid_t stopProcess(unsigned int killWait);
    virtual ENGINE_RUNNING_STATUS getProcessStatus();
};

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;

    // enums

    enum ENGINE_RUNNING_STATUS;

    // fields

    static constexpr auto LaunchType = LAUNCH_COMMAND;

    // methods

    virtual pid_t launchProcess(
        const nlohmann::json& launcherConfig,
        const std::string& procCmd,
        const std::vector<std::string>& envParams,
        const std::vector<std::string>& startParams,
        bool appendParentEnv = true,
        int logFD = -1
    ) = 0;

    virtual pid_t stopProcess(unsigned int killWait) = 0;
    virtual ENGINE_RUNNING_STATUS getProcessStatus();
    virtual std::string_view launchType() const = 0;
    virtual std::string_view launchType() const;

Detailed Documentation

Methods

virtual pid_t launchProcess(
    const nlohmann::json& launcherConfig,
    const std::string& procCmd,
    const std::vector<std::string>& envParams,
    const std::vector<std::string>& startParams,
    bool appendParentEnv = true,
    int logFD = -1
)

Fork a new process for the given engine. Will read environment variables and start params from engineConfig The function should take the environment parameters and start parameters defined in engineConfig, and append any additional strings defined in envParams and startParams before starting the Engine specified in engineConfig. If appendParentEnv is set to true, use the parent environment in the forked child. If set to false, scrub the environment before continuing.

Parameters:

launcherConfig

Configuration specific to the launch command

procCmd

Process command

envParams

Additional Environment Variables for Engine process. Will take precedence over default env params if appendParentEnv is true

startParams

Additional Start parameters

appendParentEnv

Should parent env variables be appended to Engine process

Returns:

Returns PID of child process on success

virtual pid_t stopProcess(unsigned int killWait)

Stop a running engine process.

Parameters:

killWait

Time (in seconds) to wait for process to quit by itself before force killing it. 0 means it will wait indefinetly

Returns:

Returns 0 on success, negative value on error

virtual ENGINE_RUNNING_STATUS getProcessStatus()

Get the current engine process status. If status cannot be retrieved, return ENGINE_RUNNING_STATUS::UNKNOWN.

Returns:

Returns status as enum ProcessLauncherInterface::ENGINE_RUNNING_STATUS