Commit Graph

9 Commits

Author SHA1 Message Date
Apollon Oikonomopoulos
b3fce6ef4d MINOR: systemd wrapper: re-execute on SIGUSR2
Re-execute the systemd wrapper on SIGUSR2 and before reloading HAProxy,
making it possible to load a completely new version of HAProxy
(including a new version of the systemd wrapper) gracefully.
Since the wrapper accepts no command-line arguments of its own,
re-execution is signaled using the HAPROXY_SYSTEMD_REEXEC environment
variable.

This is primarily intended to help seamless upgrades of distribution
packages.
2014-04-17 18:11:11 +02:00
Willy Tarreau
e5eddafa89 BUG/MEDIUM: systemd-wrapper: fix locating of haproxy binary
OpenBSD complains this way due to strncat() :

src/haproxy-systemd-wrapper.o(.text+0xd5): In function `spawn_haproxy':
src/haproxy-systemd-wrapper.c:33: warning: strcat() is almost always misused, please use strlcat()

In fact, the code before strncat() here is wrong, because it may
dereference a NULL if /proc/self/exe is not readable. So fix it
and get rid of strncat() at the same time.

No backport is needed.
2014-04-14 15:52:49 +02:00
Lukas Tribus
439cfde55b BUILD/MINOR: systemd: fix compiler warning about unused result
There is a compiler warning after commit 1b6e75fa84 ("MEDIUM: haproxy-
systemd-wrapper: Use haproxy in same directory"):

src/haproxy-systemd-wrapper.c: In function ‘locate_haproxy’:
src/haproxy-systemd-wrapper.c:28:10: warning: ignoring return value of ‘readlink’, declared with attribute warn_unused_result [-Wunused-result]

Fix the compiler warning by checking the return value of readlink().
2013-12-10 08:50:55 +01:00
Kristoffer Grnlund
f65194a6fa LOW: systemd-wrapper: Write debug information to stdout
Write the command line used to call haproxy to stdout, as
well as the return code returned by the haproxy process.
2013-11-23 12:06:51 +01:00
Kristoffer Grnlund
66fd1d830e MEDIUM: systemd-wrapper: Kill child processes when interrupted
Send SIGINT to child processes when killed. This ensures that
the haproxy process managed by the systemd-wrapper is stopped
when "systemctl stop haproxy.service" is called.
2013-11-23 12:06:51 +01:00
Kristoffer Grnlund
1b6e75fa84 MEDIUM: haproxy-systemd-wrapper: Use haproxy in same directory
Locate the wrapper and use a haproxy executable found in the
same directory.

This patch lets the wrapper work in openSUSE.
2013-11-23 12:06:50 +01:00
Willy Tarreau
9046bbf05b BUILD: stdbool is not portable (again)
Another build issue on Solaris without c99. Please don't use stdbool.
2013-05-01 10:09:30 +02:00
Marc-Antoine Perennou
47f922dd24 BUG/MEDIUM: systemd-wrapper: don't leak zombie processes
Formerly, if A was replaced by B, and then B by C before
A finished exiting, we didn't wait for B to finish so it
ended up as a zombie process.
Fix this by waiting randomly every child we spawn.

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2013-04-02 14:34:51 +02:00
Marc-Antoine Perennou
ed9803e606 MEDIUM: add haproxy-systemd-wrapper
Currently, to reload haproxy configuration, you have to use "-sf".

There is a problem with this way of doing things. First of all, in the systemd world,
reload commands should be "oneshot" ones, which means they should not be the new main
process but rather a tool which makes a call to it and then exits. With the current approach,
the reload command is the new main command and moreover, it makes the previous one exit.
Systemd only tracks the main program, seeing it ending, it assumes it either finished or failed,
and kills everything remaining as a grabage collector. We then end up with no haproxy running
at all.

This patch adds wrapper around haproxy, no changes at all have been made into it,
so it's not intrusive and doesn't change anything for other hosts. What this wrapper does
is basically launching haproxy as a child, listen to the SIGUSR2 (not to conflict with
haproxy itself) signal, and spawing a new haproxy with "-sf" as a child to relay the
first one.

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2013-02-13 10:47:56 +01:00