Main  /  Edit version 1  /  Edit version 2  /   /  Users Area

Difference "Reload the application" ver. 1 versus ver. 2

Content:

Sometimes you want to update the configuration file and gracefully reload the application. Here is a way to do so.
Among [Unix Signals](http://en.wikipedia.org/wiki/Unix_signal), [SIGHUP](http://en.wikipedia.org/wiki/SIGHUP) can be used to restart an application (SIGHUP allows child processes to gracefully exist after they have completed the current job).
Here is how you can use it it your application's code:
static cppcms::service* srv;
static bool got_sighup;
handler()
{
got_sighup = true;
srv->shutdown();
}
And in main():
while(1) {
cppcms::service srv(...)
srv.run();
if(got_sighup) {
got_sighup = false;
continue;
}
break;
}
So when the application gets SIGHUP, it restarts and reloads the configuration file. It exits upon SIGTERM.
Sometimes you want to update the configuration file and gracefully reload the application. Here is a way to do so.
Among [Unix Signals](http://en.wikipedia.org/wiki/Unix_signal), [SIGHUP](http://en.wikipedia.org/wiki/SIGHUP) can be used to restart an application (SIGHUP allows child processes to gracefully exist after they have completed the current job).
Here is how you can use it it your application's code:
static cppcms::service* srv;
static bool got_sighup;
handler()
{
got_sighup = true;
srv->shutdown();
}
And in main():
while(1) {
cppcms::service srv(...)
srv.run();
if(got_sighup) {
got_sighup = false;
continue;
}
break;
}
So when the application gets SIGHUP, it restarts and reloads the configuration file. It exits upon SIGTERM.

Sidebar:

← [Encoding and UTF-8](http://cppcms.com/wikipp/en/page/cppcms_1x_encoding_and_utf8)
[Howto](http://cppcms.com/wikipp/en/page/cppcms_1x_howto)→

About

CppCMS is a web development framework for performance demanding applications.

Support This Project

SourceForge.net Logo

Поддержать проект

CppCMS needs You


Navigation

Main Page


Valid CSS | Valid XHTML 1.0