-x <unix_socket> : connect to the specified socket and try to retrieve any
listening sockets from the old process, and use them instead of trying to
bind new ones. This is useful to avoid missing any new connection when
- reloading the configuration on Linux. The capability must be enable on the
- stats socket using "expose-fd listeners" in your configuration.
- In master-worker mode, the master will use this option upon a reload with
- the "sockpair@" syntax, which allows the master to connect directly to a
- worker without using stats socket declared in the configuration.
+ reloading the configuration on Linux.
+
+ Without master-worker mode, the capability must be enable on the stats
+ socket using "expose-fd listeners" in your configuration.
+
+ In master-worker mode, it does not need "expose-fd listeners", the master
+ will use automatically this option upon a reload with the "sockpair@"
+ syntax, which allows the master to connect directly to a worker without using
+ any stats socket declared in the configuration. If you want to disable this,
+ you can pass -x /dev/null.
A safe way to start HAProxy from an init file consists in forcing the daemon
mode, storing existing pids to a pid file and using this pid file to notify
char *msg = NULL;
struct rlimit limit;
struct mworker_proc *current_child = NULL;
+ int x_off = 0; /* disable -x by putting -x /dev/null */
mworker_block_signals();
setenv("HAPROXY_MWORKER_REEXEC", "1", 1);
/* copy the program name */
next_argv[next_argc++] = old_argv[0];
+ /* we need to reintroduce /dev/null everytime */
+ if (old_unixsocket && strcmp(old_unixsocket, "/dev/null") == 0)
+ x_off = 1;
+
/* insert the new options just after argv[0] in case we have a -- */
if (getenv("HAPROXY_MWORKER_WAIT_ONLY") == NULL) {
msg = NULL;
}
}
-
- if (current_child) {
+ if (!x_off && current_child) {
/* add the -x option with the socketpair of the current worker */
next_argv[next_argc++] = "-x";
if ((next_argv[next_argc++] = memprintf(&msg, "sockpair@%d", current_child->ipc_fd[0])) == NULL)
}
}
+ if (x_off) {
+ /* if the cmdline contained a -x /dev/null, continue to use it */
+ next_argv[next_argc++] = "-x";
+ next_argv[next_argc++] = "/dev/null";
+ }
+
/* copy the previous options */
for (i = 1; i < old_argc; i++)
next_argv[next_argc++] = old_argv[i];