Difference "Reload the application" ver. 2 versus ver. 3
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.
|
|
|
---
|
|
← [Encoding and UTF-8][prev]
|
| [Top](#maincontent)
|
| [Howto][next] →
|
|
[prev]: /wikipp/en/page/cppcms_1x_encoding_and_utf8
|
[next]: /wikipp/en/page/cppcms_1x_howto |
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)→ |
|
## Browse
|
|
[CppCMS 1.x.x - Stable][toc]
|
|
← [Encoding and UTF-8][prev]
|
[Howto][next] →
|
|
[toc]: /wikipp/en/page/cppcms_1x
|
[prev]: /wikipp/en/page/cppcms_1x_encoding_and_utf8
|
[next]: /wikipp/en/page/cppcms_1x_howto |
About
CppCMS is a web development framework for performance demanding applications.
Support This Project
Navigation
Main Page
Valid CSS
| Valid XHTML 1.0