simplify logic for disabling service manager on windows

This commit is contained in:
Jeff Becker 2022-10-28 13:04:05 -04:00
parent 84834089d1
commit a16af792d2
No known key found for this signature in database
GPG Key ID: 025C02EE3A092F2D
1 changed files with 4 additions and 8 deletions

View File

@ -34,8 +34,6 @@ insert_description();
#endif
bool run_as_daemon{false};
static auto logcat = llarp::log::Cat("main");
std::shared_ptr<llarp::Context> ctx;
std::promise<int> exit_code;
@ -340,21 +338,19 @@ main(int argc, char* argv[])
{strdup("lokinet"), (LPSERVICE_MAIN_FUNCTION)win32_daemon_entry}, {NULL, NULL}};
if (std::string{argv[1]} == "--win32-daemon")
{
run_as_daemon = true;
StartServiceCtrlDispatcher(DispatchTable);
return StartServiceCtrlDispatcher(DispatchTable);
}
else
{
llarp::sys::service_manager->disable();
return lokinet_main(argc, argv);
}
#endif
}
int
lokinet_main(int argc, char** argv)
{
// if we are not running as a service disable reporting
if (llarp::platform::is_windows and not run_as_daemon)
llarp::sys::service_manager->disable();
if (auto result = Lokinet_INIT())
return result;