NRP Core  1.4.1
basic_fork.h
Go to the documentation of this file.
1 /* * NRP Core - Backend infrastructure to synchronize simulations
2  *
3  * Copyright 2020-2023 NRP Team
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * This project has received funding from the European Union’s Horizon 2020
18  * Framework Programme for Research and Innovation under the Specific Grant
19  * Agreement No. 945539 (Human Brain Project SGA3).
20  */
21 
22 #ifndef BASIC_FORK_H
23 #define BASIC_FORK_H
24 
25 #include "nrp_general_library/config/cmake_constants.h"
27 
28 inline const char LAUNCH_COMMAND[] = "BasicFork";
29 
30 class BasicFork
31  : public LaunchCommand<LAUNCH_COMMAND>
32 {
36  static constexpr std::string_view EnvCfgCmd = NRP_ENGINE_SET_ENV_CMD;
37 
38  public:
39  ~BasicFork() override;
40 
41  pid_t launchProcess(const nlohmann::json &launcherConfig, const std::string& procCmd,
42  const std::vector<std::string> &envParams,
43  const std::vector<std::string> &startParams, bool appendParentEnv = true,
44  int logFD = -1) override;
45 
46  pid_t stopProcess(unsigned int killWait) override;
47 
49 
50  private:
54  pid_t _PID;
55 
60  static void appendEnvVars(const std::vector<std::string> &envVars);
61 };
62 
63 #endif // BASIC_FORK_H
BasicFork::getProcessStatus
ENGINE_RUNNING_STATUS getProcessStatus() override
Get the current engine process status. If status cannot be retrieved, return ENGINE_RUNNING_STATUS::U...
Definition: basic_fork.cpp:202
launch_command.h
BasicFork::stopProcess
pid_t stopProcess(unsigned int killWait) override
Stop a running engine process.
Definition: basic_fork.cpp:157
BasicFork::launchProcess
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) override
Fork a new process for the given engine. Will read environment variables and start params from engine...
Definition: basic_fork.cpp:44
LaunchCommand
Class for launch commands. Must be specialized further.
Definition: launch_command.h:93
BasicFork::~BasicFork
~BasicFork() override
Definition: basic_fork.cpp:36
LaunchCommandInterface::ENGINE_RUNNING_STATUS
ENGINE_RUNNING_STATUS
Engine Process status.
Definition: launch_command.h:39
BasicFork
Definition: basic_fork.h:30
LAUNCH_COMMAND
const char LAUNCH_COMMAND[]
Definition: basic_fork.h:28
json
nlohmann::json json
Definition: engine_json_server.cpp:31