[Cppcms-users] Shutdown issue
Brought to you by:
artyom-beilis
|
From: Sab <rim...@gm...> - 2013-03-14 09:03:38
|
Hallo Artyom,
I am running the cppcms::service in a separate thread. When the calling thread
restarts, I would also like to restart the cppcms service. On restart, I am
calling service.shutdown() from the main tread that executed it. I see the log
before the shutdown call but the log after the call is not printed -> I suspect
that the function hangs up because after the application exits the process still
keeps running in the background. This is my application’s main:
(Sorry for the code formatting...)
int main(int argc, char* argv[])
{
. . .
do
{
. . .
//start WebService
WebService webService(connector);
LOG_MAIN << "Starting the WebService thread";
boost::thread webServiceThread(webService);
. . .
while ( system.IsRunning() && !shutdownSignalReceived )
{
. . .
}
//stop WebService
LOG_MAIN << "Stopping WebService...";
webService.ShutDown();
webServiceThread.join();
. . .
}
while (runState == Common::Devices::Run::Reload);
}
------------------
My WebService class:
void WebService::operator()()
{
try
{
. . .
m_service = new cppcms::service(serviceConfig);
m_service->applications_pool().
mount(cppcms::applications_factory<MainWebHandler>
(m_connector));
m_service->run();
delete m_service;
}
catch(std::exception const &e)
{
LOG_MAIN_ERROR << "WebService exception: " << e.what();
}
}
void WebService::ShutDown()
{
try
{
cout << "Shutting down WebService..." << endl;
m_service->shutdown();
cout << "Shutting down WebService finished." << endl;
}
catch(std::exception const &e)
{
LOG_MAIN_ERROR << "WebService exception: " << e.what();
}
}
---------------
I don't get any error or exception. As mentioned I see the log “Shutting down
WebService...” but I don’t see “Shutting down WebService finished.” that’s why I
think the service doesn’t shut down properly so the thread keeps running in the
background.
Do you see anything wrong with my code?
Sab
|