src/server/daemon/main.c

changeset 444
96d2ba2f28db
parent 443
ef3c8a0e1fee
child 556
b036ccad4b49
equal deleted inserted replaced
443:ef3c8a0e1fee 444:96d2ba2f28db
75 /* 75 /*
76 * SIGUSR1: reload the configuration files 76 * SIGUSR1: reload the configuration files
77 */ 77 */
78 void sig_usr1_reload(int sig) { 78 void sig_usr1_reload(int sig) {
79 log_ereport(LOG_INFORM, "sig reload"); 79 log_ereport(LOG_INFORM, "sig reload");
80 80 (void)webserver_reconfig();
81 CfgManager mgr;
82 if(cfgmgr_load_config(&mgr) != 0) {
83 log_ereport(LOG_FAILURE, "cannot reload server.conf");
84 } else {
85 if(cfgmgr_apply_config(&mgr)) {
86 log_ereport(LOG_FAILURE, "cannot reload config");
87 }
88 }
89
90 // start newly created listeners
91 start_all_listener();
92
93 signal(SIGUSR1, sig_usr1_reload); 81 signal(SIGUSR1, sig_usr1_reload);
94 } 82 }
95 83
96 /* 84 /*
97 * SIGTERM: stop the server 85 * SIGTERM: stop the server
267 if(init_logging()) { 255 if(init_logging()) {
268 fprintf(stderr, "OOM\n"); 256 fprintf(stderr, "OOM\n");
269 return 1; 257 return 1;
270 } 258 }
271 259
272 is_daemon = 1;
273 if(is_daemon) { 260 if(is_daemon) {
274 // initialize startup pipes 261 // initialize startup pipes
275 if(pipe(daemon_start_pipe)) { 262 if(pipe(daemon_start_pipe)) {
276 perror("pipe"); 263 perror("pipe");
277 return EXIT_FAILURE; 264 return EXIT_FAILURE;
322 for(int i=0;i<3;i++) { 309 for(int i=0;i<3;i++) {
323 close(i); 310 close(i);
324 } 311 }
325 312
326 dup2(std_out[1], 1); 313 dup2(std_out[1], 1);
327 //dup2(std_err[1], 2); 314 dup2(std_err[1], 2);
328 close(std_out[1]); 315 close(std_out[1]);
329 //close(std_err[1]); 316 close(std_err[1]);
330 317
331 // set log thread stack size 318 // set log thread stack size
332 pthread_attr_t tattr; 319 pthread_attr_t tattr;
333 pthread_attr_init(&tattr); 320 pthread_attr_init(&tattr);
334 pthread_attr_setstacksize(&tattr, LOG_THREAD_STACK_SIZE); 321 pthread_attr_setstacksize(&tattr, LOG_THREAD_STACK_SIZE);
369 } 356 }
370 357
371 if(srvctrl_wait()) { 358 if(srvctrl_wait()) {
372 return EXIT_FAILURE; 359 return EXIT_FAILURE;
373 } 360 }
374
375 /* TODO: join threads (or not?) */
376 /*
377 while(1) {
378 if(is_daemon) {
379 fflush(stdout);
380 fflush(stderr);
381 }
382 sleep(10000);
383 if(0) {
384 break;
385 }
386 }
387 */
388 361
389 return EXIT_SUCCESS; 362 return EXIT_SUCCESS;
390 } 363 }
391 364

mercurial