winss
|
The svscan template. More...
#include <svscan.hpp>
Public Member Functions | |
SvScanTmpl (winss::NotOwningPtr< winss::WaitMultiplexer > multiplexer, const fs::path &scan_dir, DWORD rescan, bool signals, winss::EventWrapper close_event) | |
SvScan constructor. More... | |
SvScanTmpl (const SvScanTmpl &)=delete | |
No copy. More... | |
SvScanTmpl (SvScanTmpl &&)=delete | |
No move. More... | |
virtual void | Scan (bool timeout) |
Does a scan of the scan directory. More... | |
virtual void | CloseAllServices (bool ignore_flagged) |
Closes all the services. More... | |
virtual void | Exit (bool close_services) |
Signals the scanner to exit. More... | |
SvScanTmpl & | operator= (const SvScanTmpl &)=delete |
No copy. More... | |
SvScanTmpl & | operator= (SvScanTmpl &&)=delete |
No move. More... | |
Static Public Attributes | |
static const int | kMutexTaken = 100 |
Scan dir in use error. More... | |
static const int | kFatalExitCode = 111 |
Something went wrong. More... | |
static constexpr const char | kMutexName [7] = "svscan" |
Mutex name. More... | |
static constexpr const char | kTimeoutGroup [7] = "svscan" |
The timeout group for the multiplexer. More... | |
static constexpr const char | kSvscanDir [14] = ".winss-svscan" |
The directory for svscan data. More... | |
static constexpr const char | kFinishFile [7] = "finish" |
Finish file. More... | |
static constexpr const char | kSigTermFile [8] = "SIGTERM" |
SIGTERM file. More... | |
static constexpr const char | kEnvDir [18] = ".winss-svscan\\env" |
Env directory. More... | |
Protected Member Functions | |
void | Init () |
Initializes svscan. More... | |
void | Check (const fs::path &service_dir) |
Checks the given service directory. More... | |
void | Schedule () |
Schedules the next scan of the scan directory. More... | |
void | Terminate () |
Handles a signal to terminate. More... | |
void | Stop () |
Stops the svscan instance. More... | |
Static Protected Member Functions | |
static void | ReadEnv () |
Reads the env directory into the current environment. More... | |
Protected Attributes | |
winss::NotOwningPtr< winss::WaitMultiplexer > | multiplexer |
The event multiplexer for svscan. More... | |
fs::path | scan_dir |
The scan directory. More... | |
const DWORD | rescan |
The directory scan period. More... | |
TMutex | mutex |
The svscan global mutex. More... | |
bool | exiting = false |
Exiting flag. More... | |
bool | close_on_exit = true |
Option to close services on exit. More... | |
bool | signals = false |
Use handlers for signals. More... | |
winss::EventWrapper | close_event |
Event when to stop. More... | |
std::vector< TService > | services |
A list of services. More... | |
The svscan template.
Scans a directory either on a timer or on demand and starts supervisors for each service directory it sees.
TService | The service implementation type. |
TMutex | The mutex implementation type. |
TMutex | The process implementation type. |
|
inline |
SvScan constructor.
multiplexer | The shared multiplexer. |
scan_dir | The scan directory. |
rescan | The scan period. |
signals | Use handlers for signals. |
close_event | Event when to stop. |
References winss::WaitMultiplexer::AddInitCallback(), winss::WaitMultiplexer::AddStopCallback(), winss::WaitMultiplexer::AddTriggeredCallback(), winss::EventWrapper::GetHandle(), winss::SvScanTmpl< TService, TMutex, TProcess >::Init(), winss::WaitMultiplexer::RemoveTriggeredCallback(), winss::SvScanTmpl< TService, TMutex, TProcess >::Stop(), and winss::SvScanTmpl< TService, TMutex, TProcess >::Terminate().
|
delete |
No copy.
|
delete |
No move.
|
inlineprotected |
Checks the given service directory.
If the service dir has not been seen then it will be added to the list. If the service dir has been seen it will be checked to make sure it is running.
[in] | service_dir | The service directory. |
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Scan().
|
inlinevirtual |
Closes all the services.
ignore_flagged | Force the services to close. |
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Stop().
|
inlinevirtual |
Signals the scanner to exit.
close_services | Mark if the services should be closed. |
References winss::SvScanTmpl< TService, TMutex, TProcess >::operator=(), and winss::WaitMultiplexer::Stop().
|
inlineprotected |
Initializes svscan.
References FILESYSTEM, winss::SvScanTmpl< TService, TMutex, TProcess >::kFatalExitCode, winss::SvScanTmpl< TService, TMutex, TProcess >::kMutexTaken, winss::SvScanTmpl< TService, TMutex, TProcess >::kSvscanDir, winss::SvScanTmpl< TService, TMutex, TProcess >::ReadEnv(), winss::SvScanTmpl< TService, TMutex, TProcess >::Scan(), and winss::WaitMultiplexer::Stop().
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl().
|
delete |
No copy.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Exit().
|
delete |
No move.
|
inlinestaticprotected |
Reads the env directory into the current environment.
References winss::SvScanTmpl< TService, TMutex, TProcess >::kEnvDir, and WINDOWS.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Init().
|
inlinevirtual |
Does a scan of the scan directory.
References winss::SvScanTmpl< TService, TMutex, TProcess >::Check(), winss::SvScanTmpl< TService, TMutex, TProcess >::exiting, FILESYSTEM, winss::WaitMultiplexer::RemoveTimeoutCallback(), winss::SvScanTmpl< TService, TMutex, TProcess >::scan_dir, and winss::SvScanTmpl< TService, TMutex, TProcess >::Schedule().
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Init(), and winss::SvScanTmpl< TService, TMutex, TProcess >::Schedule().
|
inlineprotected |
Schedules the next scan of the scan directory.
References winss::WaitMultiplexer::AddTimeoutCallback(), winss::SvScanTmpl< TService, TMutex, TProcess >::kTimeoutGroup, and winss::SvScanTmpl< TService, TMutex, TProcess >::Scan().
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Scan().
|
inlineprotected |
Stops the svscan instance.
References winss::WaitMultiplexer::AddTriggeredCallback(), winss::SvScanTmpl< TService, TMutex, TProcess >::CloseAllServices(), winss::Utils::ExpandEnvironmentVariables(), FILESYSTEM, winss::SvScanTmpl< TService, TMutex, TProcess >::kFinishFile, winss::SvScanTmpl< TService, TMutex, TProcess >::kSvscanDir, winss::SvScanTmpl< TService, TMutex, TProcess >::kTimeoutGroup, and winss::WaitMultiplexer::RemoveTimeoutCallback().
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl().
|
inlineprotected |
Handles a signal to terminate.
References winss::WaitMultiplexer::AddTriggeredCallback(), winss::Utils::ExpandEnvironmentVariables(), FILESYSTEM, winss::EventWrapper::GetHandle(), winss::SvScanTmpl< TService, TMutex, TProcess >::kSigTermFile, winss::SvScanTmpl< TService, TMutex, TProcess >::kSvscanDir, winss::EventWrapper::Reset(), and winss::WaitMultiplexer::Stop().
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl().
|
protected |
Event when to stop.
|
protected |
Option to close services on exit.
|
protected |
Exiting flag.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Scan().
|
static |
Env directory.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::ReadEnv().
|
static |
Something went wrong.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Init().
|
static |
Finish file.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Stop().
|
static |
Mutex name.
|
static |
Scan dir in use error.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Init().
|
static |
SIGTERM file.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Terminate().
|
static |
The directory for svscan data.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Init(), winss::SvScanTmpl< TService, TMutex, TProcess >::Stop(), and winss::SvScanTmpl< TService, TMutex, TProcess >::Terminate().
|
static |
The timeout group for the multiplexer.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Schedule(), and winss::SvScanTmpl< TService, TMutex, TProcess >::Stop().
|
protected |
The event multiplexer for svscan.
|
protected |
The svscan global mutex.
|
protected |
The directory scan period.
|
protected |
The scan directory.
Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Scan().
|
protected |
A list of services.
|
protected |
Use handlers for signals.