diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-04-17 21:09:36 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-04-17 21:09:36 +0200 |
commit | d4c3033adcfa359ae0c82a0d3b1bee6a96245ba1 (patch) | |
tree | 5aa9045bd218ff3d7e8022bfb465e7bc4afa8bfb /src/main.cpp | |
download | aCms-d4c3033adcfa359ae0c82a0d3b1bee6a96245ba1.tar.gz aCms-d4c3033adcfa359ae0c82a0d3b1bee6a96245ba1.tar.bz2 |
first raw empty classes and structure
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..9005e20 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,58 @@ +#include <cppcms/service.h> +#include <cppcms/applications_pool.h> +#include <booster/log.h> + +#include <signal.h> + +#include "strusCms.hpp" + +static bool terminate = false; +static bool got_sighup = false; +static cppcms::service *global_srv = 0; + +static void handle_signal( int sig ) +{ + switch( sig ) { + case SIGHUP: + got_sighup = true; + if( global_srv ) global_srv->shutdown( ); + break; + + default: + // unknown signal, ignore + break; + } +} + +int main( int argc, char *argv[] ) +{ + signal( SIGHUP, handle_signal ); + while( !terminate ) { + cppcms::service srv( argc, argv ); + global_srv = &srv; + + try { + BOOSTER_INFO( "strusCms" ) << "Restarting application.."; + + srv.applications_pool( ).mount( cppcms::applications_factory<strusCms>( ) ); + + srv.run( ); + + if( got_sighup ) { + BOOSTER_INFO( "strusCms" ) << "Reloading configuration on SIGHUP.."; + got_sighup = false; + } else { + terminate = true; + } + + } catch( std::exception const &e ) { + BOOSTER_ERROR( "strusCms" ) << e.what() ; + srv.shutdown( ); + continue; + } + + srv.shutdown( ); + } + + return 0; +} |