Re: [Cppcms-users] Shutdown issue
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2013-03-14 09:33:48
|
Few points: a) Enable this option: http://cppcms.com/wikipp/en/page/cppcms_1x_config#service.disable_global_exit_handling to prevent from the CppCMS service to install signal handlers. b) Put the log between m_service->run(); << Log exited delete m_service; To see if service exits. And probably put log after the delete to make sure that thread competes. Note the run() would not exit until all the worker threads had completed the job. c) Why don't you put cppcms::service on the stack such that it would not leak in case of exception... you code is not exception safe. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Sab <rim...@gm...> >To: cpp...@li... >Sent: Thursday, March 14, 2013 11:03 AM >Subject: [Cppcms-users] Shutdown issue > >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 > > > >------------------------------------------------------------------------------ >Everyone hates slow websites. So do we. >Make your web apps faster with AppDynamics >Download AppDynamics Lite for free today: >http://p.sf.net/sfu/appdyn_d2d_mar >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |