mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 23:01:24 +02:00
MEDIUM: mworker/systemd: send STATUS over sd_notify
The sd_notify API is not able to change the "Active:" line in "systemcl status". However a message can still be displayed on a "Status: " line, even if the service is still green and "active (running)". When startup succeed the Status will be set to "Ready.", upon a reload it will be set to "Reloading Configuration." If the configuration succeed "Ready." again. However if the reload failed, it will be set to "Reload failed!". Keep in mind that the "Active:" line won't change upon a reload failure, and will still be green.
This commit is contained in:
parent
887a2b5bc4
commit
a46a99e98c
@ -682,10 +682,6 @@ static void mworker_reexec()
|
|||||||
struct mworker_proc *current_child = NULL;
|
struct mworker_proc *current_child = NULL;
|
||||||
|
|
||||||
mworker_block_signals();
|
mworker_block_signals();
|
||||||
#if defined(USE_SYSTEMD)
|
|
||||||
if (global.tune.options & GTUNE_USE_SYSTEMD)
|
|
||||||
sd_notify(0, "RELOADING=1");
|
|
||||||
#endif
|
|
||||||
setenv("HAPROXY_MWORKER_REEXEC", "1", 1);
|
setenv("HAPROXY_MWORKER_REEXEC", "1", 1);
|
||||||
|
|
||||||
mworker_cleanup_proc();
|
mworker_cleanup_proc();
|
||||||
@ -802,16 +798,16 @@ void mworker_reload()
|
|||||||
child->reloads++;
|
child->reloads++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_SYSTEMD)
|
||||||
|
if (global.tune.options & GTUNE_USE_SYSTEMD)
|
||||||
|
sd_notify(0, "RELOADING=1\nSTATUS=Reloading Configuration.\n");
|
||||||
|
#endif
|
||||||
mworker_reexec();
|
mworker_reexec();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mworker_loop()
|
static void mworker_loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined(USE_SYSTEMD)
|
|
||||||
if (global.tune.options & GTUNE_USE_SYSTEMD)
|
|
||||||
sd_notifyf(0, "READY=1\nMAINPID=%lu", (unsigned long)getpid());
|
|
||||||
#endif
|
|
||||||
/* Busy polling makes no sense in the master :-) */
|
/* Busy polling makes no sense in the master :-) */
|
||||||
global.tune.options &= ~GTUNE_BUSY_POLLING;
|
global.tune.options &= ~GTUNE_BUSY_POLLING;
|
||||||
|
|
||||||
@ -877,6 +873,13 @@ void reexec_on_failure()
|
|||||||
|
|
||||||
usermsgs_clr(NULL);
|
usermsgs_clr(NULL);
|
||||||
ha_warning("Loading failure!\n");
|
ha_warning("Loading failure!\n");
|
||||||
|
#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!\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
mworker_reexec_waitmode();
|
mworker_reexec_waitmode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3440,6 +3443,10 @@ int main(int argc, char **argv)
|
|||||||
mworker_loop();
|
mworker_loop();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
#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
|
||||||
/* if not in wait mode, reload in wait mode to free the memory */
|
/* if not in wait mode, reload in wait mode to free the memory */
|
||||||
ha_notice("Loading success.\n");
|
ha_notice("Loading success.\n");
|
||||||
proc_self->failedreloads = 0; /* reset the number of failure */
|
proc_self->failedreloads = 0; /* reset the number of failure */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user