From: Valentine Krasnobaeva Date: Fri, 11 Oct 2024 17:39:12 +0000 (+0200) Subject: MINOR: mworker: deserialize process list before read_cfg_in_discovery_mode X-Git-Tag: v3.1-dev10~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ee7fc983200a326113614064e3681a6c4bd4b456;p=thirdparty%2Fhaproxy.git MINOR: mworker: deserialize process list before read_cfg_in_discovery_mode This patch is a part of series to reintroduce the program support in the new master-worker architecture. For the moment we keep the order of program and worker forks the same as before the refactoring, as we need to be sure that this won't introduce regressions. So, programs are forked before the new worker process. Before the program's fork we already need deserialized processes list to find the programs launched before reload and to stop them. Processes list saved before the reload in HAPROXY_PROCESSES variable. It should be deserialized before the first configuration read in discovery mode, because resetenv keyword could be presented in the global section. So, let's move mworker_env_to_proc_list() from mworker_create_master_cli() to main(). We need to call it only after reload in master-worker mode, thus HAPROXY_MWORKER_REEXEC and HAPROXY_PROCESSES should be still presented in the re-executing process environment before the first configuration read. --- diff --git a/src/haproxy.c b/src/haproxy.c index 5ed6c7edb3..b934850cf2 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3714,6 +3714,15 @@ int main(int argc, char **argv) */ step_init_1(); + /* deserialize processes list, if we do reload in master-worker mode */ + if ((getenv("HAPROXY_MWORKER_REEXEC") != NULL)) { + if (mworker_env_to_proc_list() < 0) { + ha_alert("Master failed to deserialize monitored processes list, " + "it's a non-recoverable error, exiting.\n"); + exit(EXIT_FAILURE); + } + } + /* parse conf in disovery mode and set modes from config */ read_cfg_in_discovery_mode(argc, argv); diff --git a/src/mworker.c b/src/mworker.c index 31374eafc1..874bfd1f62 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -845,11 +845,6 @@ void mworker_create_master_cli(void) { struct wordlist *it, *c; - /* get the info of the children in the env */ - if (mworker_env_to_proc_list() < 0) { - exit(EXIT_FAILURE); - } - if (!LIST_ISEMPTY(&mworker_cli_conf)) { char *path = NULL;