diff --git a/doc/configuration.txt b/doc/configuration.txt index b45fcf073..7b7ded698 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -998,7 +998,7 @@ modes: | HAPROXY_MWORKER | X | | | | | X | X | | HAPROXY_CLI | | | | | | | X | | HAPROXY_MASTER_CLI | | | | | | X | | - | HAPROXY_LOCALPEER | | | | | | | X | + | HAPROXY_LOCALPEER | | | X | | | | X | | HAPROXY_HTTP_LOG_FMT | | | X | | X | | | | HAPROXY_HTTP_CLF_LOG_FMT | | | X | | X | | | | HAPROXY_HTTPS_LOG_FMT | | | X | | X | | | diff --git a/src/haproxy.c b/src/haproxy.c index f551a2a17..7ba287a13 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3827,6 +3827,14 @@ int main(int argc, char **argv) } setenv("HAPROXY_MWORKER", "1", 1); } + + /* localpeer default value could be redefined via 'localpeer' keyword + * from the global section, which has already parsed in MODE_DISCOVERY by + * read_cfg_in_discovery_mode(). So, let's set HAPROXY_LOCALPEER explicitly + * here. + */ + setenv("HAPROXY_LOCALPEER", localpeer, 1); + non_global_section_parsed = 0; if (read_cfg() < 0) { list_for_each_entry_safe(cfg, cfg_tmp, &cfg_cfgfiles, list) { @@ -3839,12 +3847,6 @@ int main(int argc, char **argv) list_for_each_entry_safe(cfg, cfg_tmp, &cfg_cfgfiles, list) ha_free(&cfg->content); - /* localpeer could be redefined via 'localpeer' keyword from the - * global section, in master-worker mode it's parsed only by - * worker, so let set HAPROXY_LOCALPEER explicitly here - */ - if (localpeer != NULL) - setenv("HAPROXY_LOCALPEER", localpeer, 1); usermsgs_clr(NULL); }