blob: a1a2e71a22820d95eddad4e473e9cfbe62de8684 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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<apps::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;
}
|