Main  /  Edit  /  History  /   /  Users Area

Reload the application

Sometimes you want to update the configuration file and gracefully reload the application. Here is a way to do so.

Among Unix Signals, SIGHUP can be used to restart an application (SIGHUP allows child processes to gracefully exist after they have completed the current job).

Place the code below in the global scope, before the application main(int argc,char ** argv) function:

static cppcms::service* srv;
static volatile bool got_sighup;

bool handler()
   got_sighup = true;

And in main():

   while(1) {
        srv = new cppcms::service(argc,argv);
        srv->applications_pool().mount( cppcms::applications_factory<my_application>());
        if(got_sighup) {
          got_sighup = false;

So when the application gets SIGHUP, it restarts and reloads the configuration file. It exits upon SIGTERM.

Important note (to be confirmed by Artyom): the above method does not work if in your configuration file (config.js) you have service.api = "http", i.e. if you use the internal browser. If you do, you will encounter the error: "system: Address already in use", meaning that the internal http server cannot reuse the IP same address (e.g. The method works with fastcgi or cgi.

Encoding and UTF-8 | Top | Howto


CppCMS is a web development framework for performance demanding applications.

Support This Project Logo

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

CppCMS needs You


Main Page

Valid CSS | Valid XHTML 1.0