MINOR: init: check MODE_MWORKER before creating master CLI

mworker_create_master_cli() creates MASTER proxy and allocates listeners,
which are attached to this proxy. It also creates a reload sockpair.

So, it's more appropriate to do the check, that we are in a MODE_MWORKER, if
master CLI settings were provided via command line, just after the config
parsing. And only then, if runtime mode and command line settings are
coherent, try to perform master-worker fork and try to create master CLI.
This commit is contained in:
Valentine Krasnobaeva 2024-08-09 18:05:23 +02:00 committed by Willy Tarreau
parent 26e53e2e8c
commit e4c10a704d

View File

@ -2062,6 +2062,11 @@ static void init(int argc, char **argv)
exit(1);
}
if (!LIST_ISEMPTY(&mworker_cli_conf) && !(arg_mode & MODE_MWORKER)) {
ha_alert("a master CLI socket was defined, but master-worker mode (-W) is not enabled.\n");
exit(EXIT_FAILURE);
}
if (global.mode & MODE_MWORKER) {
struct mworker_proc *tmproc;
@ -2207,11 +2212,6 @@ static void init(int argc, char **argv)
if (master)
mworker_create_master_cli();
if (!LIST_ISEMPTY(&mworker_cli_conf) && !(arg_mode & MODE_MWORKER)) {
ha_alert("a master CLI socket was defined, but master-worker mode (-W) is not enabled.\n");
exit(EXIT_FAILURE);
}
/* destroy unreferenced defaults proxies */
proxy_destroy_all_unref_defaults();