]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: init: add HTTP client-only mode
authorFrederic Lecaille <flecaille@haproxy.com>
Mon, 2 Mar 2026 10:09:04 +0000 (11:09 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Fri, 24 Apr 2026 09:32:45 +0000 (11:32 +0200)
Introduce the new <client_mode> global variable to define the operating mode
of haproxy. This variable can be set to 1 to allow haproxy to start without
any listeners.

During the initialization cycle, setting this flag 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.

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

index 1510bfe0c6d4c54ec80595b68bd7e8b917f03503..a70761232574e79690eab65b4bd00666e168b94e 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 client_mode;
 extern struct cfgfile fileless_cfg;
 
 /* storage for collected libs */
index 32702ea742151a902ceacfa83c52c8e301778cd0..741e7c853ce38e13ac3503b029cd8013593361d9 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 client_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);
@@ -3529,7 +3530,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) && !client_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. */