]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: new global directive server-state-base
authorBaptiste Assmann <bedis9@gmail.com>
Sun, 23 Aug 2015 07:22:25 +0000 (09:22 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 19 Sep 2015 15:05:26 +0000 (17:05 +0200)
This new global directive can be used to provide a base directory where
all the server state files could be loaded.
If a server state file name starts with a slash '/', then this directive
must not be applied.

include/types/global.h
src/cfgparse.c

index c2b028a12e4422471c95df0c9b58d9cde8fce339..fe1085e95921e8480c6579f637feae5a1e8ba259 100644 (file)
@@ -129,6 +129,7 @@ struct global {
        char *log_tag;                  /* name for syslog */
        struct list logsrvs;
        char *log_send_hostname;   /* set hostname in syslog header */
+       char *server_state_base;   /* path to a directory where server state files can be found */
        struct {
                int maxpollevents; /* max number of poll events at once */
                int maxaccept;     /* max number of consecutive accept() */
index 71d3fea23945877e577974bc2887c38c8e5f5013..d3ee13260ac97b1251017612538d3006711f9ec9 100644 (file)
@@ -1645,6 +1645,21 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                global.log_send_hostname = malloc(len + 2);
                snprintf(global.log_send_hostname, len + 2, "%s ", name);
        }
+       else if (!strcmp(args[0], "server-state-base")) { /* path base where HAProxy can find server state files */
+               if (global.server_state_base != NULL) {
+                       Alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]);
+                       err_code |= ERR_ALERT;
+                       goto out;
+               }
+
+               if (!*(args[1])) {
+                       Alert("parsing [%s:%d] : '%s' expects one argument: a directory path.\n", file, linenum, args[0]);
+                       err_code |= ERR_FATAL;
+                       goto out;
+               }
+
+               global.server_state_base = strdup(args[1]);
+       }
        else if (!strcmp(args[0], "log-tag")) {  /* tag to report to syslog */
                if (alertif_too_many_args(1, file, linenum, args, &err_code))
                        goto out;