chore: Clearer naming for static daemon loop functions
This commit is contained in:
parent
b425b43801
commit
bdf5a0f352
1 changed files with 21 additions and 29 deletions
|
|
@ -50,24 +50,6 @@ bool isServerCommandLine(const std::vector<std::string> &cmd)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int mainLoopStatic()
|
|
||||||
{
|
|
||||||
DaemonApp::instance().mainLoop();
|
|
||||||
return kExitSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
int unixMainLoopStatic(int, const char **)
|
|
||||||
{
|
|
||||||
return mainLoopStatic();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
|
||||||
int winMainLoopStatic(int, const char **)
|
|
||||||
{
|
|
||||||
return ArchMiscWindows::runDaemon(mainLoopStatic);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void showHelp(int argc, char **argv) // NOSONAR - CLI args
|
void showHelp(int argc, char **argv) // NOSONAR - CLI args
|
||||||
{
|
{
|
||||||
const auto binName = argc > 0 ? std::filesystem::path(argv[0]).filename().string() : "deskflow-core";
|
const auto binName = argc > 0 ? std::filesystem::path(argv[0]).filename().string() : "deskflow-core";
|
||||||
|
|
@ -77,22 +59,32 @@ void showHelp(int argc, char **argv) // NOSONAR - CLI args
|
||||||
DaemonApp::DaemonApp() = default;
|
DaemonApp::DaemonApp() = default;
|
||||||
DaemonApp::~DaemonApp() = default;
|
DaemonApp::~DaemonApp() = default;
|
||||||
|
|
||||||
|
int daemonLoop()
|
||||||
|
{
|
||||||
|
DaemonApp::instance().mainLoop();
|
||||||
|
return kExitSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SYSAPI_WIN32
|
||||||
|
int daemonLoop(int, const char **)
|
||||||
|
{
|
||||||
|
return ArchMiscWindows::runDaemon(daemonLoop);
|
||||||
|
}
|
||||||
|
#elif SYSAPI_UNIX
|
||||||
|
int daemonLoop(int, const char **)
|
||||||
|
{
|
||||||
|
return daemonLoop();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void DaemonApp::run()
|
void DaemonApp::run()
|
||||||
{
|
{
|
||||||
if (m_foreground) {
|
if (m_foreground) {
|
||||||
LOG_DEBUG("starting daemon in foreground");
|
LOG_DEBUG("running daemon in foreground");
|
||||||
|
|
||||||
// run process in foreground instead of daemonizing.
|
|
||||||
// useful for debugging.
|
|
||||||
mainLoop(m_foreground);
|
mainLoop(m_foreground);
|
||||||
} else {
|
} else {
|
||||||
#if SYSAPI_WIN32
|
LOG_DEBUG("running daemon in background (daemonizing)");
|
||||||
LOG_DEBUG("daemonizing windows service");
|
ARCH->daemonize(kAppName, daemonLoop);
|
||||||
ARCH->daemonize(kAppName, winMainLoopStatic);
|
|
||||||
#elif SYSAPI_UNIX
|
|
||||||
LOG_DEBUG("daemonizing unix service");
|
|
||||||
ARCH->daemonize(kAppName, unixMainLoopStatic);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue