mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 12:41:00 +02:00
MINOR: init: allow a fileless init mode
This patch provides the possibility to initialize haproxy without configuration file. This may be identified by the new global and exported <fileless_mode> and <fileless_cfg> variables which may be used to provide a struct cfgfile to haproxy by others means than a physical file (built in memory). When enabled, this fileless mode skips all the configuration files parsing.
This commit is contained in:
parent
234ce775c3
commit
6013f4baeb
@ -24,6 +24,7 @@
|
||||
|
||||
#include <haproxy/api-t.h>
|
||||
#include <haproxy/global-t.h>
|
||||
#include <haproxy/cfgparse.h>
|
||||
|
||||
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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user