]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: init: add no listener mode
authorFrederic Lecaille <flecaille@haproxy.com>
Mon, 2 Mar 2026 10:09:04 +0000 (11:09 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Wed, 1 Jul 2026 13:22:14 +0000 (15:22 +0200)
Introduce the new <no_listener_mode> global variable to define a new operating mode
for haproxy. This variable can be set to 1 to allow haproxy to start without
any listeners. Without such a setting, haproxy refuses to start without listener.

During the initialization cycle, setting this variable to 1 ensures that the
lack of configured listeners is no longer treated as a fatal error. This allows
programs based on haproxy source code to initialize the stack and use its
features even without a frontend. This will be the case for haload.

include/haproxy/global.h
src/haproxy.c

index 854824419e4de52f5680030dd5350980317e6807..bbd458b86fc77f9baeb8dcb2342a10df89391539 100644 (file)
@@ -56,6 +56,7 @@ extern const char *old_unixsocket;
 extern int daemon_fd[2];
 extern int devnullfd;
 extern int fileless_mode;
+extern int no_listener_mode;
 extern struct cfgfile fileless_cfg;
 
 /* storage for collected libs */
index 80423720339fdf7b00221fa1d8d1efa1fd4e99a6..19469b210abe41196907117e63dbe8d14de17618 100644 (file)
@@ -150,6 +150,7 @@ int  pidfd = -1;            /* FD to keep PID */
 int daemon_fd[2] = {-1, -1};   /* pipe to communicate with parent process */
 int devnullfd = -1;
 int fileless_mode;
+int no_listener_mode;
 struct cfgfile fileless_cfg;
 extern __attribute__((weak)) void haproxy_init_args(int argc, char **argv);
 extern __attribute__((weak)) char **copy_argv(int argc, char **argv);
@@ -3681,7 +3682,7 @@ int main(int argc, char **argv)
        }
 
        /* Exit in standalone mode, if no listeners found */
-       if (!(global.mode & MODE_MWORKER) && listeners == 0) {
+       if (!(global.mode & MODE_MWORKER) && !no_listener_mode && listeners == 0) {
                ha_alert("[%s.main()] No enabled listener found (check for 'bind' directives) ! Exiting.\n", argv[0]);
                /* Note: we don't have to send anything to the old pids because we
                 * never stopped them. */