]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: startup: don't daemonize if started with -c
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Mon, 9 Dec 2024 11:00:35 +0000 (12:00 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Dec 2024 20:32:36 +0000 (21:32 +0100)
Due to master-worker refactoring, daemonization fork happens now very early,
before parsing and verifying the configuration. For the moment there is no
any specific syntax, which needs for the daemon mode to be really applied in
order to perform the tests.

So, it's better not to do the daemonization fork, if 'daemon' keyword is
presented in the config (or -D option), when we started with -c (MODE_CHECK).
Like this, during the config verification, the process will always stay in
foreground and all warning or errors will be delivered to the stdout.

This fix should be backported only in 3.1.

src/haproxy.c

index 34c29d170430f3532b6bee699ebd2d044eba72c1..94faab41cb117c3ddd69f837f87fa77b85bc7d9a 100644 (file)
@@ -3366,7 +3366,8 @@ int main(int argc, char **argv)
         * will become then a master) in background, before it will fork a
         * worker, because the worker should be also in background for this case.
         */
-       if ((getenv("HAPROXY_MWORKER_REEXEC") == NULL) && (global.mode & MODE_DAEMON))
+       if ((getenv("HAPROXY_MWORKER_REEXEC") == NULL) && (global.mode & MODE_DAEMON)
+           && !(global.mode & MODE_CHECK))
                apply_daemon_mode();
 
        /* Master-worker and program forks */