mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MINOR: startup: replace HAPROXY_LOAD_SUCCESS with global load_status
After master-worker refactoring, master performs re-exec only once up to receiving "reload" command or USR2 signal. There is no more the second master's re-exec to free unused memory. Thus, there is no longer need to export environment variable HAPROXY_LOAD_SUCCESS with worker process load status. This status can be simply saved in a global variable load_status.
This commit is contained in:
parent
aadda34fd6
commit
d5d41dee3d
@ -18,6 +18,7 @@
|
||||
#include <haproxy/signal-t.h>
|
||||
|
||||
extern int max_reloads;
|
||||
extern int load_status;
|
||||
extern struct mworker_proc *proc_self;
|
||||
/* master CLI configuration (-S flag) */
|
||||
extern struct list mworker_cli_conf;
|
||||
|
@ -2532,7 +2532,7 @@ static int _send_status(char **args, char *payload, struct appctx *appctx, void
|
||||
kill(proc->pid, oldpids_sig);
|
||||
}
|
||||
}
|
||||
setenv("HAPROXY_LOAD_SUCCESS", "1", 1);
|
||||
load_status = 1;
|
||||
ha_notice("Loading success.\n");
|
||||
|
||||
#if defined(USE_SYSTEMD)
|
||||
|
@ -936,7 +936,7 @@ void on_new_child_failure()
|
||||
sock_drop_unused_old_sockets();
|
||||
|
||||
usermsgs_clr(NULL);
|
||||
setenv("HAPROXY_LOAD_SUCCESS", "0", 1);
|
||||
load_status = 0;
|
||||
ha_warning("Failed to load worker!\n");
|
||||
#if defined(USE_SYSTEMD)
|
||||
/* the sd_notify API is not able to send a reload failure signal. So
|
||||
@ -3048,10 +3048,10 @@ static void run_master_in_recovery_mode(int argc, char **argv)
|
||||
struct mworker_proc *proc;
|
||||
char *errmsg = NULL;
|
||||
|
||||
/* HAPROXY_LOAD_SUCCESS is checked in cli_io_handler_show_cli_sock() to
|
||||
/* load_status is global and checked in cli_io_handler_show_cli_sock() to
|
||||
* dump master startup logs with its alerts/warnings via master CLI sock.
|
||||
*/
|
||||
setenv("HAPROXY_LOAD_SUCCESS", "0", 1);
|
||||
load_status = 0;
|
||||
|
||||
/* increment the number failed reloads */
|
||||
list_for_each_entry(proc, &proc_list, list) {
|
||||
|
@ -47,6 +47,7 @@
|
||||
|
||||
static int exitcode = -1;
|
||||
int max_reloads = INT_MAX; /* max number of reloads a worker can have until they are killed */
|
||||
int load_status; /* worker process startup status: 1 - loaded successfully; 0 - load failed */
|
||||
struct mworker_proc *proc_self = NULL; /* process structure of current process */
|
||||
struct list mworker_cli_conf = LIST_HEAD_INIT(mworker_cli_conf); /* master CLI configuration (-S flag) */
|
||||
|
||||
@ -795,7 +796,6 @@ static int cli_parse_reload(char **args, char *payload, struct appctx *appctx, v
|
||||
static int cli_io_handler_show_loadstatus(struct appctx *appctx)
|
||||
{
|
||||
struct mworker_proc *proc;
|
||||
char *env;
|
||||
|
||||
if (!cli_has_level(appctx, ACCESS_LVL_OPER))
|
||||
return 1;
|
||||
@ -810,15 +810,11 @@ static int cli_io_handler_show_loadstatus(struct appctx *appctx)
|
||||
}
|
||||
}
|
||||
|
||||
env = getenv("HAPROXY_LOAD_SUCCESS");
|
||||
if (!env)
|
||||
return 1;
|
||||
|
||||
if (strcmp(env, "0") == 0) {
|
||||
if (load_status == 0)
|
||||
chunk_printf(&trash, "Success=0\n");
|
||||
} else if (strcmp(env, "1") == 0) {
|
||||
else
|
||||
chunk_printf(&trash, "Success=1\n");
|
||||
}
|
||||
|
||||
#ifdef USE_SHM_OPEN
|
||||
if (startup_logs && ring_data(startup_logs) > 1)
|
||||
chunk_appendf(&trash, "--\n");
|
||||
|
Loading…
Reference in New Issue
Block a user