err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
- setenv("HAPROXY_LOCALPEER", localpeer, 1);
}
else if (strcmp(args[0], "numa-cpu-mapping") == 0) {
global.numa_cpu_mapping = (kwm == KWM_NO) ? 0 : 1;
/* preset some environment variables */
localpeer = strdup(hostname);
- if (!localpeer || setenv("HAPROXY_LOCALPEER", localpeer, 1) < 0) {
+ if (!localpeer) {
ha_alert("Cannot allocate memory for local peer.\n");
exit(EXIT_FAILURE);
}
ha_alert("Cannot allocate memory for local peer.\n");
exit(EXIT_FAILURE);
}
- setenv("HAPROXY_LOCALPEER", localpeer, 1);
global.localpeer_cmdline = 1;
break;
case 'f' :
/* all sections have been parsed, we can free the content */
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);
}