66 |
#include "process.h" |
#include "process.h" |
67 |
#include "md5.h" |
#include "md5.h" |
68 |
#include "sha.h" |
#include "sha.h" |
69 |
|
#include "state.h" |
70 |
|
|
71 |
|
|
72 |
/** |
/** |
73 |
* DESCRIPTION |
* DESCRIPTION |
111 |
*/ |
*/ |
112 |
int main(int argc, char **argv) { |
int main(int argc, char **argv) { |
113 |
|
|
114 |
prog= stripfilename(argv[0]); |
prog= Util_basename(argv[0]); |
115 |
init_env(); |
init_env(); |
116 |
handle_options(argc, argv); |
handle_options(argc, argv); |
117 |
|
|
187 |
*/ |
*/ |
188 |
if(! Run.controlfile) { |
if(! Run.controlfile) { |
189 |
|
|
190 |
Run.controlfile= find_rcfile(); |
Run.controlfile= File_findControlFile(); |
191 |
|
|
192 |
} |
} |
193 |
|
|
241 |
/* |
/* |
242 |
* Initialize Runtime file variables |
* Initialize Runtime file variables |
243 |
*/ |
*/ |
244 |
init_files(); |
File_init(); |
245 |
|
|
246 |
/* |
/* |
247 |
* Should we print debug information ? |
* Should we print debug information ? |
248 |
*/ |
*/ |
249 |
if(Run.debug) { |
if(Run.debug) { |
250 |
|
|
251 |
printrunlist(); |
Util_printRunList(); |
252 |
printservicelist(); |
Util_printServiceList(); |
253 |
|
|
254 |
} |
} |
255 |
|
|
297 |
} |
} |
298 |
|
|
299 |
/* Reinitialize Runtime file variables */ |
/* Reinitialize Runtime file variables */ |
300 |
init_files(); |
File_init(); |
301 |
|
|
302 |
if(! create_pidfile(Run.pidfile)) { |
if(! File_createPidFile(Run.pidfile)) { |
303 |
log("%s daemon died\n", prog); |
log("%s daemon died\n", prog); |
304 |
exit(1); |
exit(1); |
305 |
} |
} |
306 |
|
|
307 |
/* Update service data from the state repository */ |
/* Update service data from the state repository */ |
308 |
state_update(); |
State_update(); |
309 |
|
|
310 |
/* Start http interface */ |
/* Start http interface */ |
311 |
if(can_http()) |
if(can_http()) |
451 |
if(Run.init != TRUE) |
if(Run.init != TRUE) |
452 |
daemonize(); |
daemonize(); |
453 |
|
|
454 |
if(! create_pidfile(Run.pidfile)) { |
if(! File_createPidFile(Run.pidfile)) { |
455 |
log("%s daemon died\n", prog); |
log("%s daemon died\n", prog); |
456 |
exit(1); |
exit(1); |
457 |
} |
} |
458 |
|
|
459 |
if(state_should_update()) |
if(State_shouldUpdate()) |
460 |
state_update(); |
State_update(); |
461 |
|
|
462 |
atexit(finalize_files); |
atexit(File_finalize); |
463 |
|
|
464 |
if(can_http()) |
if(can_http()) |
465 |
monit_http(START_HTTP); |
monit_http(START_HTTP); |
467 |
for(;;) { |
for(;;) { |
468 |
|
|
469 |
validate(); |
validate(); |
470 |
state_save(); |
State_save(); |
471 |
sleep(Run.polltime); |
sleep(Run.polltime); |
472 |
|
|
473 |
if(Run.doreload) |
if(Run.doreload) |
551 |
|
|
552 |
case 'H': |
case 'H': |
553 |
if (argc > optind) { |
if (argc > optind) { |
554 |
printhash(argv[optind]); |
Util_printHash(argv[optind]); |
555 |
} else { |
} else { |
556 |
printhash(NULL); |
Util_printHash(NULL); |
557 |
} |
} |
558 |
|
|
559 |
exit(0); |
exit(0); |