diff --git a/include/haproxy/global.h b/include/haproxy/global.h index b4a7a406b..522af4162 100644 --- a/include/haproxy/global.h +++ b/include/haproxy/global.h @@ -24,6 +24,7 @@ #include #include +#include extern struct global global; extern int pid; /* current process id */ @@ -54,6 +55,8 @@ extern char **old_argv; extern const char *old_unixsocket; extern int daemon_fd[2]; extern int devnullfd; +extern int fileless_mode; +extern struct cfgfile fileless_cfg; struct proxy; struct server; diff --git a/src/haproxy.c b/src/haproxy.c index d1da0c3e3..c7e89ae1e 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -150,6 +150,8 @@ char **init_env; /* to keep current process env variables backup */ int pidfd = -1; /* FD to keep PID */ int daemon_fd[2] = {-1, -1}; /* pipe to communicate with parent process */ int devnullfd = -1; +int fileless_mode; +struct cfgfile fileless_cfg; static int stopped_tgroups; static int stop_detected; @@ -3375,8 +3377,16 @@ int main(int argc, char **argv) if (backup_env() != 0) exit(EXIT_FAILURE); - /* parse conf in discovery mode and set modes from config */ - read_cfg_in_discovery_mode(argc, argv); + if (!fileless_mode) + /* parse conf in discovery mode and set modes from config */ + read_cfg_in_discovery_mode(argc, argv); + else { + int ret; + + ret = parse_cfg(&fileless_cfg); + if (ret != 0) + exit(EXIT_FAILURE); + } /* From this stage all runtime modes are known. So let's do below some * preparation steps and then let's apply all discovered modes. @@ -3418,8 +3428,10 @@ int main(int argc, char **argv) mworker_apply_master_worker_mode(); } - /* Worker, daemon, foreground modes read the rest of the config */ - if (!master) { + /* Worker, daemon, foreground, configuration with files modes read the rest + * of the config. + */ + if (!master && !fileless_mode) { usermsgs_clr("config"); if (global.mode & MODE_MWORKER) { if (clean_env() != 0) {