Skip to content

Commit

Permalink
move embedded haproxy process to a distinct pid group
Browse files Browse the repository at this point in the history
The embedded haproxy process is being created in the same pid group of
the controller, which makes it receive the same signals received by the
controller when running under a process supervisor. This makes haproxy
be prematurely terminated when the controller is still shutting down.
  • Loading branch information
jcmoraisjr committed Jun 13, 2024
1 parent 7bd9908 commit d8bc567
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ RUN mkdir -p /var/empty /etc/haproxy /var/lib/haproxy /var/run/haproxy\

STOPSIGNAL SIGTERM
USER haproxy

# dumb-init reaps the old haproxy process in the embedded, non master-worker mode,
# after receiving SIGUSR1, avoiding it to become a zombie.
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/start.sh"]
1 change: 1 addition & 0 deletions pkg/haproxy/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ func (i *instance) startHAProxySync() {
"-f", i.options.HAProxyCfgDir)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
if err := cmd.Start(); err != nil {
i.logger.Error("error starting haproxy: %v", err)
return
Expand Down
3 changes: 3 additions & 0 deletions rootfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ RUN mkdir -p /var/empty /etc/haproxy /var/lib/haproxy /var/run/haproxy\

STOPSIGNAL SIGTERM
USER haproxy

# dumb-init reaps the old haproxy process in the embedded, non master-worker mode,
# after receiving SIGUSR1, avoiding it to become a zombie.
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/start.sh"]

0 comments on commit d8bc567

Please sign in to comment.