1
0

Merge pull request #2901 from birkett/servicefix

Fix running as a service.
This commit is contained in:
Julian Laubstein 2016-01-22 09:42:37 +01:00
commit b093e8e813
2 changed files with 6 additions and 10 deletions

View File

@ -92,7 +92,8 @@ void cRoot::InputThread(cRoot & a_Params)
} }
// We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running // We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running
if (!std::cin.good()) // Ignore this when running as a service, cin was never opened in that case
if (!std::cin.good() && !m_RunAsService)
{ {
// Stop the server: // Stop the server:
a_Params.QueueExecuteConsoleCommand("stop"); a_Params.QueueExecuteConsoleCommand("stop");
@ -232,15 +233,7 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
{ {
m_StopEvent.Wait(); m_StopEvent.Wait();
if (m_TerminateEventRaised && m_RunAsService) break;
{
// Dont kill if running as a service
m_TerminateEventRaised = false;
}
else
{
break;
}
} }
// Stop the server: // Stop the server:

View File

@ -495,6 +495,9 @@ int main(int argc, char ** argv)
} }
#endif #endif
// Make sure m_RunAsService is set correctly before checking it's value
ParseArguments(argc, argv);
// Attempt to run as a service // Attempt to run as a service
if (cRoot::m_RunAsService) if (cRoot::m_RunAsService)
{ {