diff --git a/src/cli.c b/src/cli.c index a18ff8f23..578957699 100644 --- a/src/cli.c +++ b/src/cli.c @@ -26,6 +26,10 @@ #include +#if defined(USE_SYSTEMD) +#include +#endif + #include #include #include @@ -2498,6 +2502,10 @@ static int _send_status(char **args, char *payload, struct appctx *appctx, void setenv("HAPROXY_LOAD_SUCCESS", "1", 1); ha_notice("Loading success.\n"); +#if defined(USE_SYSTEMD) + if (global.tune.options & GTUNE_USE_SYSTEMD) + sd_notifyf(0, "READY=1\nMAINPID=%lu\nSTATUS=Ready.\n", (unsigned long)getpid()); +#endif return 1; } diff --git a/src/haproxy.c b/src/haproxy.c index d88d5fa27..4e25aedea 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3016,6 +3016,12 @@ static void run_master_in_recovery_mode(int argc, char **argv) list_for_each_entry(proc, &proc_list, list) { proc->failedreloads++; } +#if defined(USE_SYSTEMD) + /* the sd_notify API is not able to send a reload failure signal. So + * the READY=1 signal still need to be sent */ + if (global.tune.options & GTUNE_USE_SYSTEMD) + sd_notify(0, "READY=1\nSTATUS=Reload failed (master failed to load or to parse new configuration)!\n"); +#endif global.nbtgroups = 1; global.nbthread = 1; @@ -4038,10 +4044,6 @@ int main(int argc, char **argv) ha_free(&msg); } -#if defined(USE_SYSTEMD) - if (global.tune.options & GTUNE_USE_SYSTEMD) - sd_notifyf(0, "READY=1\nMAINPID=%lu\nSTATUS=Ready.\n", (unsigned long)getpid()); -#endif /* Finally, start the poll loop for the first thread */ run_thread_poll_loop(&ha_thread_info[0]);