mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-22 13:46:52 +00:00
MINOR: mworker: store and shows loading status
The environment variable HAPROXY_LOAD_SUCCESS stores "1" if it successfully load the configuration and started, "0" otherwise. The "_loadstatus" master CLI command displays either "Loading failure!\n" or "Loading success.\n"
This commit is contained in:
parent
479cb3ed3a
commit
68192b2cdf
@ -866,6 +866,7 @@ void reexec_on_failure()
|
||||
sock_drop_unused_old_sockets();
|
||||
|
||||
usermsgs_clr(NULL);
|
||||
setenv("HAPROXY_LOAD_SUCCESS", "0", 1);
|
||||
ha_warning("Loading failure!\n");
|
||||
#if defined(USE_SYSTEMD)
|
||||
/* the sd_notify API is not able to send a reload failure signal. So
|
||||
@ -3507,6 +3508,7 @@ int main(int argc, char **argv)
|
||||
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 */
|
||||
setenv("HAPROXY_LOAD_SUCCESS", "1", 1);
|
||||
ha_notice("Loading success.\n");
|
||||
proc_self->failedreloads = 0; /* reset the number of failure */
|
||||
mworker_reexec_waitmode();
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <haproxy/fd.h>
|
||||
#include <haproxy/global.h>
|
||||
#include <haproxy/list.h>
|
||||
#include <haproxy/log.h>
|
||||
#include <haproxy/listener.h>
|
||||
#include <haproxy/mworker.h>
|
||||
#include <haproxy/peers.h>
|
||||
@ -656,6 +657,28 @@ static int cli_parse_reload(char **args, char *payload, struct appctx *appctx, v
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Displays if the current reload failed or succeed */
|
||||
static int cli_parse_status(char **args, char *payload, struct appctx *appctx, void *private)
|
||||
{
|
||||
char *env;
|
||||
|
||||
if (!cli_has_level(appctx, ACCESS_LVL_OPER))
|
||||
return 1;
|
||||
|
||||
env = getenv("HAPROXY_LOAD_SUCCESS");
|
||||
if (!env)
|
||||
return 1;
|
||||
|
||||
if (strcmp(env, "0") == 0) {
|
||||
return cli_msg(appctx, LOG_INFO, "Loading failure!\n");
|
||||
} else if (strcmp(env, "1") == 0) {
|
||||
return cli_msg(appctx, LOG_INFO, "Loading success.\n");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int mworker_parse_global_max_reloads(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int linenum, char **err)
|
||||
@ -714,6 +737,7 @@ static struct cli_kw_list cli_kws = {{ },{
|
||||
{ { "@master", NULL }, "@master : send a command to the master process", cli_parse_default, NULL, NULL, NULL, ACCESS_MASTER_ONLY},
|
||||
{ { "show", "proc", NULL }, "show proc : show processes status", cli_parse_default, cli_io_handler_show_proc, NULL, NULL, ACCESS_MASTER_ONLY},
|
||||
{ { "reload", NULL }, "reload : reload haproxy", cli_parse_reload, NULL, NULL, NULL, ACCESS_MASTER_ONLY},
|
||||
{ { "_loadstatus", NULL }, NULL, cli_parse_status, NULL, NULL, NULL, ACCESS_MASTER_ONLY},
|
||||
{{},}
|
||||
}};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user