17 #ifndef LIB_WINSS_SVSCAN_SERVICE_PROCESS_HPP_ 18 #define LIB_WINSS_SVSCAN_SERVICE_PROCESS_HPP_ 23 #include "easylogging/easylogging++.hpp" 24 #include "../handle_wrapper.hpp" 25 #include "../process.hpp" 28 namespace fs = std::experimental::filesystem;
48 template<
typename TProcess>
56 static constexpr
const char kSuperviseExe[16] =
"winss-supervise";
69 service_dir(std::move(service_dir)) {}
79 service_dir(std::move(p.service_dir)),
80 proc(std::move(p.proc)) {}
97 return proc.IsCreated();
107 if (proc.IsCreated()) {
109 <<
"Process for service dir " 111 <<
" is already running";
115 VLOG(3) <<
"Starting service " << service_dir;
117 std::string cmd = kSuperviseExe + std::string(
SUFFIX) +
".exe" 118 " \"" + service_dir.string() +
"\"";
136 if (proc.IsCreated()) {
152 service_dir = std::move(p.service_dir);
153 proc = std::move(p.proc);
171 #endif // LIB_WINSS_SVSCAN_SERVICE_PROCESS_HPP_ fs::path service_dir
The service directory.
Definition: service_process.hpp:51
ServiceProcessTmpl(ServiceProcessTmpl &&p)
Creates a new service process and moves it from an old one.
Definition: service_process.hpp:78
A wrapper for a Windows HANDLE.
Definition: handle_wrapper.hpp:39
Parameters to start a Windows process.
Definition: process.hpp:29
TProcess proc
The supervisor process.
Definition: service_process.hpp:52
ServiceProcessTmpl()
The default service process template constructor.
Definition: service_process.hpp:61
virtual const fs::path & GetServiceDir() const
Gets the path of the service directory.
Definition: service_process.hpp:87
virtual void Close()
Closes the service process.
Definition: service_process.hpp:135
Definition: case_ignore.hpp:23
winss::HandleWrapper stdin_pipe
Definition: service_process.hpp:35
virtual bool IsCreated() const
Gets the service process is created.
Definition: service_process.hpp:96
ServiceProcessTmpl & operator=(ServiceProcessTmpl &&p)
Moves the service process object to this object.
Definition: service_process.hpp:151
virtual void Start(const ServicePipes &pipes, bool consumer)
Starts the service process.
Definition: service_process.hpp:106
virtual ~ServiceProcessTmpl()
Service process destructor which will close the process.
Definition: service_process.hpp:160
A template for a service process.
Definition: service_process.hpp:49
winss::HandleWrapper stdin_pipe
STDIN pipe.
Definition: process.hpp:35
ServiceProcessTmpl(fs::path service_dir)
Initializes the service process with the service directory.
Definition: service_process.hpp:68
winss::HandleWrapper stdout_pipe
Definition: service_process.hpp:36
ServiceProcessTmpl< winss::Process > ServiceProcess
Concrete service process implementation.
Definition: service_process.hpp:168
#define SUFFIX
Definition: winss.hpp:23
Holds the STDIN and STDOUT pipes for redirecting.
Definition: service_process.hpp:34