]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
* added the -sf/-st command-line arguments which are used to specify
authorwilly tarreau <willy@wtap.(none)>
Sat, 25 Mar 2006 17:53:50 +0000 (18:53 +0100)
committerwilly tarreau <willy@wtap.(none)>
Sat, 25 Mar 2006 19:33:42 +0000 (20:33 +0100)
  a list of pids to send a FINISH or TERMINATE signal upon startup.
  They will also be asked to release their port if a bind fails.

haproxy.c

index c555e2a89c72089c6da8d90ad8d5a38394edd308..7083b1c5eeaf962c75816098d445c608a72ce9e9 100644 (file)
--- a/haproxy.c
+++ b/haproxy.c
@@ -703,10 +703,11 @@ static int stopping = 0;  /* non zero means stopping in progress */
 static struct timeval now = {0,0};     /* the current date at any moment */
 static struct proxy defproxy;          /* fake proxy used to assign default values on all instances */
 
-/* Here we store informations about the pids of the processes we
- * may pause or kill.
+/* Here we store informations about the pids of the processes we may pause
+ * or kill. We will send them a signal every 10 ms until we can bind to all
+ * our ports. With 200 retries, that's about 2 seconds.
  */
-#define MAX_START_RETRIES      100
+#define MAX_START_RETRIES      200
 static int nb_oldpids = 0;
 static int *oldpids = NULL;
 static int oldpids_sig; /* use USR1 or TERM */
@@ -902,6 +903,7 @@ void usage(char *name) {
 #if defined(ENABLE_POLL)
            "        -dp disables poll() usage even when available\n"
 #endif
+           "        -sf/-st [pid ]* finishes/terminates old pids. Must be last arguments.\n"
            "\n",
            name, DEFAULT_MAXCONN, cfg_maxpconn);
     exit(1);
@@ -8048,6 +8050,26 @@ void init(int argc, char **argv) {
            else if (*flag == 'l')
                arg_mode |= MODE_LOG;
 #endif
+           else if (*flag == 's' && (flag[1] == 'f' || flag[1] == 't')) {
+               /* list of pids to finish ('f') or terminate ('t') */
+
+               if (flag[1] == 'f')
+                   oldpids_sig = SIGUSR1; /* finish then exit */
+               else
+                   oldpids_sig = SIGTERM; /* terminate immediately */
+               argv++; argc--;
+
+               if (argc > 0) {
+                   oldpids = calloc(argc, sizeof(int));
+                   while (argc > 0) {
+                       oldpids[nb_oldpids] = atol(*argv);
+                       if (oldpids[nb_oldpids] <= 0)
+                           usage(old_argv);
+                       argc--; argv++;
+                       nb_oldpids++;
+                   }
+               }
+           }
            else { /* >=2 args */
                argv++; argc--;
                if (argc == 0)
@@ -8065,7 +8087,7 @@ void init(int argc, char **argv) {
        }
        else
            usage(old_argv);
-           argv++; argc--;
+       argv++; argc--;
     }
 
     global.mode = MODE_STARTING | /* during startup, we want most of the alerts */