diff --git a/include/proto/checks.h b/include/proto/checks.h index bf771ea5e..3c6eb7ff9 100644 --- a/include/proto/checks.h +++ b/include/proto/checks.h @@ -27,7 +27,6 @@ const char *get_check_status_description(short check_status); const char *get_check_status_info(short check_status); -int start_checks(); void __health_adjust(struct server *s, short status); int trigger_resolution(struct server *s); diff --git a/src/checks.c b/src/checks.c index 8eb2c7a45..b1e45499f 100644 --- a/src/checks.c +++ b/src/checks.c @@ -2331,9 +2331,10 @@ static int start_check_task(struct check *check, int mininter, /* * Start health-check. - * Returns 0 if OK, -1 if error, and prints the error in this case. + * Returns 0 if OK, ERR_FATAL on error, and prints the error in this case. */ -int start_checks() { +static int start_checks() +{ struct proxy *px; struct server *s; @@ -2352,7 +2353,7 @@ int start_checks() { if (s->slowstart) { if ((t = task_new()) == NULL) { Alert("Starting [%s:%s] check: out of memory.\n", px->id, s->id); - return -1; + return ERR_ALERT | ERR_FATAL; } /* We need a warmup task that will be called when the server * state switches from down to up. @@ -2396,7 +2397,7 @@ int start_checks() { if ((px->options2 & PR_O2_CHK_ANY) == PR_O2_EXT_CHK) { if (init_pid_list()) { Alert("Starting [%s] check: out of memory.\n", px->id); - return -1; + return ERR_ALERT | ERR_FATAL; } } @@ -2405,17 +2406,17 @@ int start_checks() { if (s->check.state & CHK_ST_CONFIGURED) { if (s->check.type == PR_O2_EXT_CHK) { if (!prepare_external_check(&s->check)) - return -1; + return ERR_ALERT | ERR_FATAL; } if (!start_check_task(&s->check, mininter, nbcheck, srvpos)) - return -1; + return ERR_ALERT | ERR_FATAL; srvpos++; } /* A task for a auxiliary agent check */ if (s->agent.state & CHK_ST_CONFIGURED) { if (!start_check_task(&s->agent, mininter, nbcheck, srvpos)) { - return -1; + return ERR_ALERT | ERR_FATAL; } srvpos++; } @@ -3455,6 +3456,12 @@ int srv_check_healthcheck_port(struct check *chk) return 0; } +__attribute__((constructor)) +static void __check_init(void) +{ + hap_register_post_check(start_checks); +} + /* * Local variables: diff --git a/src/haproxy.c b/src/haproxy.c index 780ca3c1a..5d43cf388 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -89,7 +89,6 @@ #include #include #include -#include #include #include #include @@ -946,9 +945,6 @@ static void init(int argc, char **argv) } } - if (start_checks() < 0) - exit(1); - list_for_each_entry(pcf, &post_check_list, list) { err_code |= pcf->fct(); if (err_code & (ERR_ABORT|ERR_FATAL))