/* Daemon init sequence */ static void start_check(void) { /* Initialize sub-system */ ipvs_start(); init_checkers_queue(); #ifdef _WITH_VRRP_ init_interface_queue(); kernel_netlink_init(); #endif #ifdef _WITH_SNMP_ if (!reload && snmp) check_snmp_agent_init(); #endif /* Parse configuration file */ global_data = alloc_global_data(); check_data = alloc_check_data(); init_data(conf_file, check_init_keywords); if (!check_data) { stop_check(); return; } /* Post initializations */ log_message(LOG_INFO, "Configuration is using : %lu Bytes", mem_allocated); /* SSL load static data & initialize common ctx context */ if (!init_ssl_ctx()) { stop_check(); return; } /* Processing differential configuration parsing */ if (reload) { clear_diff_services(); copy_srv_states(); } /* Initialize IPVS topology */ if (!init_services()) { stop_check(); return; } /* Dump configuration */ if (debug & 4) { dump_global_data(global_data); dump_check_data(check_data); } #ifdef _WITH_VRRP_ /* Initialize linkbeat */ init_interface_linkbeat(); #endif /* Register checkers thread */ register_checkers_thread(); }
/* Daemon init sequence */ static void start_check(void) { /* Initialize sub-system */ if (ipvs_start() != IPVS_SUCCESS) { stop_check(KEEPALIVED_EXIT_FATAL); return; } init_checkers_queue(); #ifdef _WITH_VRRP_ init_interface_queue(); kernel_netlink_init(); #endif /* Parse configuration file */ global_data = alloc_global_data(); check_data = alloc_check_data(); if (!check_data) stop_check(KEEPALIVED_EXIT_FATAL); init_data(conf_file, check_init_keywords); init_global_data(global_data); /* Post initializations */ #ifdef _MEM_CHECK_ log_message(LOG_INFO, "Configuration is using : %zu Bytes", mem_allocated); #endif /* Remove any entries left over from previous invocation */ if (!reload && global_data->lvs_flush) ipvs_flush_cmd(); #ifdef _WITH_SNMP_CHECKER_ if (!reload && global_data->enable_snmp_checker) check_snmp_agent_init(global_data->snmp_socket); #endif /* SSL load static data & initialize common ctx context */ if (!init_ssl_ctx()) stop_check(KEEPALIVED_EXIT_FATAL); /* fill 'vsg' members of the virtual_server_t structure. * We must do that after parsing config, because * vs and vsg declarations may appear in any order */ link_vsg_to_vs(); /* Set the process priority and non swappable if configured */ if (global_data->checker_process_priority) set_process_priority(global_data->checker_process_priority); if (global_data->checker_no_swap) set_process_dont_swap(4096); /* guess a stack size to reserve */ /* Processing differential configuration parsing */ if (reload) clear_diff_services(); /* Initialize IPVS topology */ if (!init_services()) stop_check(KEEPALIVED_EXIT_FATAL); /* Dump configuration */ if (__test_bit(DUMP_CONF_BIT, &debug)) { dump_global_data(global_data); dump_check_data(check_data); } #ifdef _WITH_VRRP_ /* Initialize linkbeat */ init_interface_linkbeat(); #endif /* Register checkers thread */ register_checkers_thread(); }
/* Register CHECK thread */ int start_check_child(void) { #ifndef _DEBUG_ pid_t pid; int ret; char *syslog_ident; /* Initialize child process */ pid = fork(); if (pid < 0) { log_message(LOG_INFO, "Healthcheck child process: fork error(%s)" , strerror(errno)); return -1; } else if (pid) { checkers_child = pid; log_message(LOG_INFO, "Starting Healthcheck child process, pid=%d" , pid); /* Start respawning thread */ thread_add_child(master, check_respawn_thread, NULL, pid, RESPAWN_TIMER); return 0; } if ((instance_name #if HAVE_DECL_CLONE_NEWNET || network_namespace #endif ) && (check_syslog_ident = make_syslog_ident(PROG_CHECK))) syslog_ident = check_syslog_ident; else syslog_ident = PROG_CHECK; /* Opening local CHECK syslog channel */ openlog(syslog_ident, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0) , (log_facility==LOG_DAEMON) ? LOG_LOCAL2 : log_facility); #ifdef _MEM_CHECK_ mem_log_init(PROG_CHECK, "Healthcheck child process"); #endif free_parent_mallocs_startup(true); /* Child process part, write pidfile */ if (!pidfile_write(checkers_pidfile, getpid())) { log_message(LOG_INFO, "Healthcheck child process: cannot write pidfile"); exit(KEEPALIVED_EXIT_FATAL); } /* Create the new master thread */ signal_handler_destroy(); thread_destroy_master(master); /* This destroys any residual settings from the parent */ master = thread_make_master(); /* change to / dir */ ret = chdir("/"); if (ret < 0) { log_message(LOG_INFO, "Healthcheck child process: error chdir"); } /* Set mask */ umask(0); #endif /* If last process died during a reload, we can get there and we * don't want to loop again, because we're not reloading anymore. */ UNSET_RELOAD; /* Signal handling initialization */ check_signal_init(); /* Start Healthcheck daemon */ start_check(); /* Launch the scheduling I/O multiplexer */ launch_scheduler(); /* Finish healthchecker daemon process */ stop_check(EXIT_SUCCESS); /* unreachable */ exit(EXIT_SUCCESS); }
/* Daemon init sequence */ static void start_check(void) { /* Initialize sub-system */ if (ipvs_start() != IPVS_SUCCESS) { stop_check(); return; } init_checkers_queue(); #ifdef _WITH_VRRP_ init_interface_queue(); kernel_netlink_init(); #endif #ifdef _WITH_SNMP_ if (!reload && snmp) check_snmp_agent_init(snmp_socket); #endif /* Parse configuration file */ global_data = alloc_global_data(); check_data = alloc_check_data(); init_data(conf_file, check_init_keywords); if (!check_data) { stop_check(); return; } init_global_data(global_data); /* Post initializations */ #ifdef _DEBUG_ log_message(LOG_INFO, "Configuration is using : %lu Bytes", mem_allocated); #endif /* SSL load static data & initialize common ctx context */ if (!init_ssl_ctx()) { stop_check(); return; } /* fill 'vsg' members of the virtual_server_t structure. * We must do that after parsing config, because * vs and vsg declarations may appear in any order */ link_vsg_to_vs(); /* Processing differential configuration parsing */ if (reload) clear_diff_services(); /* Initialize IPVS topology */ if (!init_services()) { stop_check(); return; } /* Dump configuration */ if (__test_bit(DUMP_CONF_BIT, &debug)) { dump_global_data(global_data); dump_check_data(check_data); } #ifdef _WITH_VRRP_ /* Initialize linkbeat */ init_interface_linkbeat(); #endif /* Register checkers thread */ register_checkers_thread(); }
/* Register CHECK thread */ int start_check_child(void) { #ifndef _DEBUG_ pid_t pid; int ret; /* Initialize child process */ pid = fork(); if (pid < 0) { log_message(LOG_INFO, "Healthcheck child process: fork error(%s)" , strerror(errno)); return -1; } else if (pid) { checkers_child = pid; log_message(LOG_INFO, "Starting Healthcheck child process, pid=%d" , pid); /* Start respawning thread */ thread_add_child(master, check_respawn_thread, NULL, pid, RESPAWN_TIMER); return 0; } /* Opening local CHECK syslog channel */ openlog(PROG_CHECK, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0) , (log_facility==LOG_DAEMON) ? LOG_LOCAL2 : log_facility); /* Child process part, write pidfile */ if (!pidfile_write(checkers_pidfile, getpid())) { log_message(LOG_INFO, "Healthcheck child process: cannot write pidfile"); exit(0); } /* Create the new master thread */ signal_handler_destroy(); thread_destroy_master(master); master = thread_make_master(); /* change to / dir */ ret = chdir("/"); if (ret < 0) { log_message(LOG_INFO, "Healthcheck child process: error chdir"); } /* Set mask */ umask(0); #endif /* If last process died during a reload, we can get there and we * don't want to loop again, because we're not reloading anymore. */ UNSET_RELOAD; /* Signal handling initialization */ check_signal_init(); /* Start Healthcheck daemon */ start_check(); /* Launch the scheduling I/O multiplexer */ launch_scheduler(); /* Finish healthchecker daemon process */ stop_check(); exit(0); }