MINOR: cli: implements 'reload' on master CLI
The reload command reload the haproxy master like it is done with a kill
-USR2 on the master process.
diff --git a/doc/management.txt b/doc/management.txt
index 21719f4..a01ba96 100644
--- a/doc/management.txt
+++ b/doc/management.txt
@@ -2588,6 +2588,16 @@
$ echo '@1; show info; show stat; @2; show info; show stat' | socat /var/run/haproxy-master.sock -
[...]
+You can also reload the HAProxy master process with the "reload" command which
+does the same as a `kill -USR2` on the master process, provided that the user
+has at least "operator" or "admin" privileges.
+
+Example:
+
+ $ echo "reload" | socat /var/run/haproxy-master.sock
+
+Note that a reload will close the connection to the master CLI.
+
10. Tricks for easier configuration management
----------------------------------------------
diff --git a/include/types/global.h b/include/types/global.h
index 0d1c4e2..16fce72 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -247,6 +247,7 @@
void hap_register_per_thread_deinit(void (*fct)());
void mworker_accept_wrapper(int fd);
+void mworker_reload();
/* simplified way to declare static build options in a file */
#define REGISTER_BUILD_OPTS(str) \
diff --git a/src/cli.c b/src/cli.c
index 1a2253c..23caac3 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1318,6 +1318,17 @@
return 1;
}
+/* reload the master process */
+static int cli_parse_reload(char **args, char *payload, struct appctx *appctx, void *private)
+{
+ if (!cli_has_level(appctx, ACCESS_LVL_OPER))
+ return 1;
+
+ mworker_reload();
+
+ return 1;
+}
+
int cli_parse_default(char **args, char *payload, struct appctx *appctx, void *private)
{
return 0;
@@ -2619,6 +2630,7 @@
{ { "show", "proc", NULL }, "show proc : show processes status", cli_parse_default, cli_io_handler_show_proc, NULL, NULL, ACCESS_MASTER_ONLY},
{ { "operator", NULL }, "operator : lower the level of the current CLI session to operator", cli_parse_set_lvl, NULL, NULL, NULL, ACCESS_MASTER},
{ { "user", NULL }, "user : lower the level of the current CLI session to user", cli_parse_set_lvl, NULL, NULL, NULL, ACCESS_MASTER},
+ { { "reload", NULL }, "reload : reload haproxy", cli_parse_reload, NULL, NULL, NULL, ACCESS_MASTER_ONLY},
{ { "_getsocks", NULL }, NULL, _getsocks, NULL },
{{},}
}};
diff --git a/src/haproxy.c b/src/haproxy.c
index 20fc1de..994e39c 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -708,7 +708,7 @@
* When called, this function reexec haproxy with -sf followed by current
* children PIDs and possibly old children PIDs if they didn't leave yet.
*/
-static void mworker_reload()
+void mworker_reload()
{
int next_argc = 0;
int j;