BUG/MINOR: startup: fix pidfile creation
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Mon, 2 Dec 2024 15:05:16 +0000 (16:05 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Dec 2024 14:35:44 +0000 (15:35 +0100)
commit4e1af7c8560dd08ad88134b23c464201c58cbd95
tree0b0f5da09526b20f7fc5036f20538a59b91a8695
parent82c291b3b5720e3a8573c5d4e59b4a18b8aca2d8
BUG/MINOR: startup: fix pidfile creation

Pidfile should be created at the latest initialization stage, when we are
sure, that process is able to start successfully, otherwise PID value, written
in this file is no longer valid.

So, for the standalone mode, let's move the block, which opens the pidfile and
let's put it just before applying "chroot". In master-worker mode, master
doesn't perform chroot. So it creates the pidfile, only when the "READY"
message from the newly forked worker is received.

This should be backported only in 3.1

(cherry picked from commit 295071007b1bf83eb0d66ad88b05d6aef05c69eb)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/cli.c
src/haproxy.c