Skip to content

Commit 6e2036b

Browse files
committed
shutdown command file worker on errors
otherwise naemon hangs during errors on start
1 parent 6088565 commit 6e2036b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/naemon/naemon.c

+11-8
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,6 @@ int main(int argc, char **argv)
556556
nerd_init();
557557
timing_point("Initialized NERD\n");
558558

559-
/* read in all object config data */
560-
if (result == OK) {
561-
nm_log(NSLOG_INFO_MESSAGE, "Reading all config object data\n");
562-
timing_point("Reading all object data\n");
563-
result = read_all_object_data(config_file);
564-
timing_point("Read all object data\n");
565-
}
566-
567559
/*
568560
* the queue has to be initialized before loading the neb modules
569561
* to give them the chance to register user events.
@@ -581,6 +573,16 @@ int main(int argc, char **argv)
581573
launch_command_file_worker();
582574
timing_point("Launched command file worker\n");
583575

576+
/* read in all object config data after launching the command worker
577+
* to keep the memory footprint of the command worker smaller
578+
*/
579+
if (result == OK) {
580+
nm_log(NSLOG_INFO_MESSAGE, "Reading all config object data\n");
581+
timing_point("Reading all object data\n");
582+
result = read_all_object_data(config_file);
583+
timing_point("Read all object data\n");
584+
}
585+
584586
/* initialize check workers */
585587
timing_point("Spawning %u workers\n", wproc_num_workers_spawned);
586588
if (init_workers(num_check_workers) < 0) {
@@ -604,6 +606,7 @@ int main(int argc, char **argv)
604606
nm_log(NSLOG_CONFIG_ERROR, "Error: Module loading failed. Aborting.\n");
605607
/* give already loaded modules a chance to deinitialize */
606608
neb_unload_all_modules(NEBMODULE_FORCE_UNLOAD, NEBMODULE_NEB_SHUTDOWN);
609+
shutdown_command_file_worker();
607610
exit(EXIT_FAILURE);
608611
}
609612
timing_point("Loaded modules\n");

0 commit comments

Comments
 (0)