MINOR: systemd wrapper: add support for passing the -x option.
Make the systemd wrapper chech if HAPROXY_STATS_SOCKET if set. If set, it will use it as an argument to the "-x" option, which makes haproxy asks for any listening socket, on the stats socket, in order to achieve reloads with no new connection lost.
This commit is contained in:
parent
547408787f
commit
2c9744fe56
@ -3,6 +3,8 @@ Description=HAProxy Load Balancer
|
|||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
# You can point the environment variable HAPROXY_STATS_SOCKET to a stats
|
||||||
|
# socket if you want seamless reloads.
|
||||||
Environment="CONFIG=/etc/haproxy/haproxy.cfg" "PIDFILE=/run/haproxy.pid"
|
Environment="CONFIG=/etc/haproxy/haproxy.cfg" "PIDFILE=/run/haproxy.pid"
|
||||||
ExecStartPre=@SBINDIR@/haproxy -f $CONFIG -c -q
|
ExecStartPre=@SBINDIR@/haproxy -f $CONFIG -c -q
|
||||||
ExecStart=@SBINDIR@/haproxy-systemd-wrapper -f $CONFIG -p $PIDFILE
|
ExecStart=@SBINDIR@/haproxy-systemd-wrapper -f $CONFIG -p $PIDFILE
|
||||||
|
@ -92,11 +92,15 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
|
|||||||
pid = fork();
|
pid = fork();
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
char **argv;
|
char **argv;
|
||||||
|
char *stats_socket = NULL;
|
||||||
int i;
|
int i;
|
||||||
int argno = 0;
|
int argno = 0;
|
||||||
|
|
||||||
/* 3 for "haproxy -Ds -sf" */
|
/* 3 for "haproxy -Ds -sf" */
|
||||||
argv = calloc(4 + main_argc + nb_pid + 1, sizeof(char *));
|
if (nb_pid > 0)
|
||||||
|
stats_socket = getenv("HAPROXY_STATS_SOCKET");
|
||||||
|
argv = calloc(4 + main_argc + nb_pid + 1 +
|
||||||
|
(stats_socket != NULL ? 2 : 0), sizeof(char *));
|
||||||
if (!argv) {
|
if (!argv) {
|
||||||
fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: failed to calloc(), please try again later.\n");
|
fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: failed to calloc(), please try again later.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -121,6 +125,10 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
|
|||||||
argv[argno++] = "-sf";
|
argv[argno++] = "-sf";
|
||||||
for (i = 0; i < nb_pid; ++i)
|
for (i = 0; i < nb_pid; ++i)
|
||||||
argv[argno++] = pid_strv[i];
|
argv[argno++] = pid_strv[i];
|
||||||
|
if (stats_socket != NULL) {
|
||||||
|
argv[argno++] = "-x";
|
||||||
|
argv[argno++] = stats_socket;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
argv[argno] = NULL;
|
argv[argno] = NULL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user