blob: abc67bd8b85d8b03b9e9acb833b172a86e9710a3 [file] [log] [blame]
William Lallemand48dfbbd2019-04-01 11:29:53 +02001/*
2 * Master Worker
3 *
4 * Copyright HAProxy Technologies 2019 - William Lallemand <wlallemand@haproxy.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
William Lallemand3fa724d2019-04-01 11:29:55 +020013#include <errno.h>
14#include <fcntl.h>
15#include <signal.h>
William Lallemand48dfbbd2019-04-01 11:29:53 +020016#include <stdlib.h>
17#include <string.h>
William Lallemande25473c2019-04-01 11:29:56 +020018#include <sys/wait.h>
William Lallemand48dfbbd2019-04-01 11:29:53 +020019
William Lallemand88dc7c52019-04-01 11:30:01 +020020#include <common/initcall.h>
William Lallemand48dfbbd2019-04-01 11:29:53 +020021#include <common/mini-clist.h>
22
William Lallemand88dc7c52019-04-01 11:30:01 +020023#include <types/cli.h>
24#include <types/global.h>
25#include <types/peers.h>
26#include <types/signal.h>
27
28#include <proto/cli.h>
William Lallemand3fa724d2019-04-01 11:29:55 +020029#include <proto/fd.h>
30#include <proto/listener.h>
William Lallemande25473c2019-04-01 11:29:56 +020031#include <proto/log.h>
William Lallemand48dfbbd2019-04-01 11:29:53 +020032#include <proto/mworker.h>
William Lallemand88dc7c52019-04-01 11:30:01 +020033#include <proto/proxy.h>
William Lallemand3cd95d22019-04-01 11:29:54 +020034#include <proto/signal.h>
William Lallemand88dc7c52019-04-01 11:30:01 +020035#include <proto/stream.h>
36#include <proto/stream_interface.h>
William Lallemand48dfbbd2019-04-01 11:29:53 +020037
William Lallemand48dfbbd2019-04-01 11:29:53 +020038
William Lallemande25473c2019-04-01 11:29:56 +020039#if defined(USE_SYSTEMD)
40#include <systemd/sd-daemon.h>
41#endif
42
43static int exitcode = -1;
44
William Lallemande25473c2019-04-01 11:29:56 +020045/* ----- children processes handling ----- */
William Lallemand48dfbbd2019-04-01 11:29:53 +020046
William Lallemand48dfbbd2019-04-01 11:29:53 +020047/*
William Lallemande25473c2019-04-01 11:29:56 +020048 * Send signal to every known children.
49 */
50
51static void mworker_kill(int sig)
52{
William Lallemand3f128872019-04-01 11:29:59 +020053 struct mworker_proc *child;
William Lallemande25473c2019-04-01 11:29:56 +020054
William Lallemand3f128872019-04-01 11:29:59 +020055 list_for_each_entry(child, &proc_list, list) {
56 /* careful there, we must be sure that the pid > 0, we don't want to emit a kill -1 */
William Lallemand32b69012019-04-16 17:42:42 +020057 if ((child->options & (PROC_O_TYPE_WORKER|PROC_O_TYPE_PROG)) && (child->pid > 0))
William Lallemand3f128872019-04-01 11:29:59 +020058 kill(child->pid, sig);
William Lallemande25473c2019-04-01 11:29:56 +020059 }
60}
61
62
63/* return 1 if a pid is a current child otherwise 0 */
William Lallemand3f128872019-04-01 11:29:59 +020064int mworker_current_child(int pid)
William Lallemande25473c2019-04-01 11:29:56 +020065{
William Lallemand3f128872019-04-01 11:29:59 +020066 struct mworker_proc *child;
William Lallemande25473c2019-04-01 11:29:56 +020067
William Lallemand3f128872019-04-01 11:29:59 +020068 list_for_each_entry(child, &proc_list, list) {
William Lallemand8f7069a2019-04-12 16:09:23 +020069 if ((child->options & (PROC_O_TYPE_WORKER|PROC_O_TYPE_PROG)) && (!(child->options & PROC_O_LEAVING)) && (child->pid == pid))
William Lallemande25473c2019-04-01 11:29:56 +020070 return 1;
71 }
72 return 0;
73}
74
William Lallemand3f128872019-04-01 11:29:59 +020075/*
76 * Return the number of new and old children (including workers and external
77 * processes)
78 */
79int mworker_child_nb()
80{
81 struct mworker_proc *child;
82 int ret = 0;
83
84 list_for_each_entry(child, &proc_list, list) {
William Lallemand8f7069a2019-04-12 16:09:23 +020085 if (child->options & (PROC_O_TYPE_WORKER|PROC_O_TYPE_PROG))
William Lallemand3f128872019-04-01 11:29:59 +020086 ret++;
87 }
88
89 return ret;
90}
91
92
William Lallemande25473c2019-04-01 11:29:56 +020093/*
William Lallemand48dfbbd2019-04-01 11:29:53 +020094 * serialize the proc list and put it in the environment
95 */
96void mworker_proc_list_to_env()
97{
98 char *msg = NULL;
99 struct mworker_proc *child;
100
101 list_for_each_entry(child, &proc_list, list) {
William Lallemand8f7069a2019-04-12 16:09:23 +0200102 char type = '?';
103
104 if (child->options & PROC_O_TYPE_MASTER)
105 type = 'm';
106 else if (child->options & PROC_O_TYPE_PROG)
107 type = 'e';
108 else if (child->options &= PROC_O_TYPE_WORKER)
109 type = 'w';
110
William Lallemand48dfbbd2019-04-01 11:29:53 +0200111 if (child->pid > -1)
William Lallemand8f7069a2019-04-12 16:09:23 +0200112 memprintf(&msg, "%s|type=%c;fd=%d;pid=%d;rpid=%d;reloads=%d;timestamp=%d;id=%s", msg ? msg : "", type, child->ipc_fd[0], child->pid, child->relative_pid, child->reloads, child->timestamp, child->id ? child->id : "");
William Lallemand48dfbbd2019-04-01 11:29:53 +0200113 }
114 if (msg)
115 setenv("HAPROXY_PROCESSES", msg, 1);
116}
117
118/*
119 * unserialize the proc list from the environment
120 */
121void mworker_env_to_proc_list()
122{
123 char *msg, *token = NULL, *s1;
124
125 msg = getenv("HAPROXY_PROCESSES");
126 if (!msg)
127 return;
128
129 while ((token = strtok_r(msg, "|", &s1))) {
130 struct mworker_proc *child;
131 char *subtoken = NULL;
132 char *s2;
133
134 msg = NULL;
135
136 child = calloc(1, sizeof(*child));
137
138 while ((subtoken = strtok_r(token, ";", &s2))) {
139
140 token = NULL;
141
142 if (strncmp(subtoken, "type=", 5) == 0) {
William Lallemand8f7069a2019-04-12 16:09:23 +0200143 char type;
144
145 type = *(subtoken+5);
146 if (type == 'm') { /* we are in the master, assign it */
William Lallemand48dfbbd2019-04-01 11:29:53 +0200147 proc_self = child;
William Lallemand8f7069a2019-04-12 16:09:23 +0200148 child->options |= PROC_O_TYPE_MASTER;
149 } else if (type == 'e') {
150 child->options |= PROC_O_TYPE_PROG;
151 } else if (type == 'w') {
152 child->options |= PROC_O_TYPE_WORKER;
153 }
154
William Lallemand48dfbbd2019-04-01 11:29:53 +0200155 } else if (strncmp(subtoken, "fd=", 3) == 0) {
156 child->ipc_fd[0] = atoi(subtoken+3);
157 } else if (strncmp(subtoken, "pid=", 4) == 0) {
158 child->pid = atoi(subtoken+4);
159 } else if (strncmp(subtoken, "rpid=", 5) == 0) {
160 child->relative_pid = atoi(subtoken+5);
161 } else if (strncmp(subtoken, "reloads=", 8) == 0) {
162 /* we reloaded this process once more */
163 child->reloads = atoi(subtoken+8) + 1;
164 } else if (strncmp(subtoken, "timestamp=", 10) == 0) {
165 child->timestamp = atoi(subtoken+10);
William Lallemand9a1ee7a2019-04-01 11:30:02 +0200166 } else if (strncmp(subtoken, "id=", 3) == 0) {
167 child->id = strdup(subtoken+3);
William Lallemand48dfbbd2019-04-01 11:29:53 +0200168 }
169 }
William Lallemand9a1ee7a2019-04-01 11:30:02 +0200170 if (child->pid) {
William Lallemand48dfbbd2019-04-01 11:29:53 +0200171 LIST_ADDQ(&proc_list, &child->list);
William Lallemand9a1ee7a2019-04-01 11:30:02 +0200172 } else {
173 free(child->id);
William Lallemand48dfbbd2019-04-01 11:29:53 +0200174 free(child);
William Lallemand9a1ee7a2019-04-01 11:30:02 +0200175
176 }
William Lallemand45286112019-04-12 16:09:21 +0200177 /* this is a process inherited from a reload that should be leaving */
178 child->options |= PROC_O_LEAVING;
William Lallemand48dfbbd2019-04-01 11:29:53 +0200179 }
180
181 unsetenv("HAPROXY_PROCESSES");
182}
William Lallemand3cd95d22019-04-01 11:29:54 +0200183
184/* Signal blocking and unblocking */
185
186void mworker_block_signals()
187{
188 sigset_t set;
189
190 sigemptyset(&set);
191 sigaddset(&set, SIGUSR1);
192 sigaddset(&set, SIGUSR2);
193 sigaddset(&set, SIGHUP);
194 sigaddset(&set, SIGCHLD);
195 ha_sigmask(SIG_SETMASK, &set, NULL);
196}
197
198void mworker_unblock_signals()
199{
200 haproxy_unblock_signals();
201}
William Lallemand3fa724d2019-04-01 11:29:55 +0200202
William Lallemande25473c2019-04-01 11:29:56 +0200203/* ----- mworker signal handlers ----- */
204
205/*
206 * When called, this function reexec haproxy with -sf followed by current
207 * children PIDs and possibly old children PIDs if they didn't leave yet.
208 */
209void mworker_catch_sighup(struct sig_handler *sh)
210{
211 mworker_reload();
212}
213
214void mworker_catch_sigterm(struct sig_handler *sh)
215{
216 int sig = sh->arg;
217
218#if defined(USE_SYSTEMD)
219 if (global.tune.options & GTUNE_USE_SYSTEMD) {
220 sd_notify(0, "STOPPING=1");
221 }
222#endif
223 ha_warning("Exiting Master process...\n");
224 mworker_kill(sig);
225}
226
227/*
228 * Wait for every children to exit
229 */
230
231void mworker_catch_sigchld(struct sig_handler *sh)
232{
233 int exitpid = -1;
234 int status = 0;
235 struct mworker_proc *child, *it;
236 int childfound;
237
238restart_wait:
239
240 childfound = 0;
241
242 exitpid = waitpid(-1, &status, WNOHANG);
243 if (exitpid > 0) {
244 if (WIFEXITED(status))
245 status = WEXITSTATUS(status);
246 else if (WIFSIGNALED(status))
247 status = 128 + WTERMSIG(status);
248 else if (WIFSTOPPED(status))
249 status = 128 + WSTOPSIG(status);
250 else
251 status = 255;
252
William Lallemand3f128872019-04-01 11:29:59 +0200253 /* delete the child from the process list */
William Lallemande25473c2019-04-01 11:29:56 +0200254 list_for_each_entry_safe(child, it, &proc_list, list) {
255 if (child->pid != exitpid)
256 continue;
257
258 LIST_DEL(&child->list);
259 close(child->ipc_fd[0]);
260 childfound = 1;
261 break;
262 }
263
William Lallemand3f128872019-04-01 11:29:59 +0200264 if (!childfound) {
265 /* We didn't find the PID in the list, that shouldn't happen but we can emit a warning */
William Lallemand9a1ee7a2019-04-01 11:30:02 +0200266 ha_warning("Process %d exited with code %d (%s)\n", exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
William Lallemande25473c2019-04-01 11:29:56 +0200267 } else {
William Lallemand9a1ee7a2019-04-01 11:30:02 +0200268 /* check if exited child is a current child */
William Lallemand45286112019-04-12 16:09:21 +0200269 if (!(child->options & PROC_O_LEAVING)) {
William Lallemand8f7069a2019-04-12 16:09:23 +0200270 if (child->options & PROC_O_TYPE_WORKER)
William Lallemand3f128872019-04-01 11:29:59 +0200271 ha_alert("Current worker #%d (%d) exited with code %d (%s)\n", child->relative_pid, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
William Lallemand8f7069a2019-04-12 16:09:23 +0200272 else if (child->options & PROC_O_TYPE_PROG)
William Lallemand9a1ee7a2019-04-01 11:30:02 +0200273 ha_alert("Current program '%s' (%d) exited with code %d (%s)\n", child->id, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
William Lallemand3f128872019-04-01 11:29:59 +0200274
William Lallemande25473c2019-04-01 11:29:56 +0200275 if (status != 0 && status != 130 && status != 143
276 && !(global.tune.options & GTUNE_NOEXIT_ONFAILURE)) {
William Lallemand9a1ee7a2019-04-01 11:30:02 +0200277 ha_alert("exit-on-failure: killing every processes with SIGTERM\n");
William Lallemande25473c2019-04-01 11:29:56 +0200278 mworker_kill(SIGTERM);
279 }
William Lallemand74f0ec32019-04-16 17:42:44 +0200280 /* 0 & SIGTERM (143) are normal, but we should report SIGINT (130) and other signals */
281 if (exitcode < 0 && status != 0 && status != 143)
282 exitcode = status;
William Lallemande25473c2019-04-01 11:29:56 +0200283 } else {
William Lallemand8f7069a2019-04-12 16:09:23 +0200284 if (child->options & PROC_O_TYPE_WORKER) {
William Lallemand3f128872019-04-01 11:29:59 +0200285 ha_warning("Former worker #%d (%d) exited with code %d (%s)\n", child->relative_pid, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
286 delete_oldpid(exitpid);
William Lallemand8f7069a2019-04-12 16:09:23 +0200287 } else if (child->options & PROC_O_TYPE_PROG) {
William Lallemand9a1ee7a2019-04-01 11:30:02 +0200288 ha_warning("Former program '%s' (%d) exited with code %d (%s)\n", child->id, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
William Lallemand3f128872019-04-01 11:29:59 +0200289 }
William Lallemande25473c2019-04-01 11:29:56 +0200290 }
291 free(child);
292 }
293
294 /* do it again to check if it was the last worker */
295 goto restart_wait;
296 }
297 /* Better rely on the system than on a list of process to check if it was the last one */
298 else if (exitpid == -1 && errno == ECHILD) {
William Lallemand4cf4b332019-04-16 17:42:43 +0200299 ha_warning("All workers exited. Exiting... (%d)\n", (exitcode > 0) ? exitcode : EXIT_SUCCESS);
William Lallemande25473c2019-04-01 11:29:56 +0200300 atexit_flag = 0;
301 if (exitcode > 0)
William Lallemand4cf4b332019-04-16 17:42:43 +0200302 exit(exitcode); /* parent must leave using the status code that provoked the exit */
303 exit(EXIT_SUCCESS);
William Lallemande25473c2019-04-01 11:29:56 +0200304 }
305
306}
307
William Lallemand3fa724d2019-04-01 11:29:55 +0200308/* ----- IPC FD (sockpair) related ----- */
309
310/* This wrapper is called from the workers. It is registered instead of the
311 * normal listener_accept() so the worker can exit() when it detects that the
312 * master closed the IPC FD. If it's not a close, we just call the regular
313 * listener_accept() function */
314void mworker_accept_wrapper(int fd)
315{
316 char c;
317 int ret;
318
319 while (1) {
320 ret = recv(fd, &c, 1, MSG_PEEK);
321 if (ret == -1) {
322 if (errno == EINTR)
323 continue;
324 if (errno == EAGAIN) {
325 fd_cant_recv(fd);
326 return;
327 }
328 break;
329 } else if (ret > 0) {
330 listener_accept(fd);
331 return;
332 } else if (ret == 0) {
333 /* At this step the master is down before
334 * this worker perform a 'normal' exit.
335 * So we want to exit with an error but
336 * other threads could currently process
337 * some stuff so we can't perform a clean
338 * deinit().
339 */
340 exit(EXIT_FAILURE);
341 }
342 }
343 return;
344}
345
346/*
347 * This function register the accept wrapper for the sockpair of the master worker
348 */
349void mworker_pipe_register()
350{
351 /* The iocb should be already initialized with listener_accept */
352 if (fdtab[proc_self->ipc_fd[1]].iocb == mworker_accept_wrapper)
353 return;
354
355 fcntl(proc_self->ipc_fd[1], F_SETFL, O_NONBLOCK);
356 /* In multi-tread, we need only one thread to process
357 * events on the pipe with master
358 */
359 fd_insert(proc_self->ipc_fd[1], fdtab[proc_self->ipc_fd[1]].owner, mworker_accept_wrapper, 1);
360 fd_want_recv(proc_self->ipc_fd[1]);
361}
William Lallemand9001ce82019-04-01 11:29:57 +0200362
363/* ----- proxies ----- */
364/*
365 * Upon a reload, the master worker needs to close all listeners FDs but the mworker_pipe
366 * fd, and the FD provided by fd@
367 */
368void mworker_cleanlisteners()
369{
370 struct listener *l, *l_next;
371 struct proxy *curproxy;
372 struct peers *curpeers;
373
374 /* we might have to unbind some peers sections from some processes */
375 for (curpeers = cfg_peers; curpeers; curpeers = curpeers->next) {
376 if (!curpeers->peers_fe)
377 continue;
378
379 stop_proxy(curpeers->peers_fe);
380 /* disable this peer section so that it kills itself */
381 signal_unregister_handler(curpeers->sighandler);
Olivier Houchard3f795f72019-04-17 22:51:06 +0200382 task_destroy(curpeers->sync_task);
William Lallemand9001ce82019-04-01 11:29:57 +0200383 curpeers->sync_task = NULL;
Olivier Houchard3f795f72019-04-17 22:51:06 +0200384 task_destroy(curpeers->peers_fe->task);
William Lallemand9001ce82019-04-01 11:29:57 +0200385 curpeers->peers_fe->task = NULL;
386 curpeers->peers_fe = NULL;
387 }
388
389 for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
390 int listen_in_master = 0;
391
392 list_for_each_entry_safe(l, l_next, &curproxy->conf.listeners, by_fe) {
393 /* remove the listener, but not those we need in the master... */
394 if (!(l->options & LI_O_MWORKER)) {
395 /* unbind the listener but does not close if
396 the FD is inherited with fd@ from the parent
397 process */
398 if (l->options & LI_O_INHERITED)
399 unbind_listener_no_close(l);
400 else
401 unbind_listener(l);
402 delete_listener(l);
403 } else {
404 listen_in_master = 1;
405 }
406 }
407 /* if the proxy shouldn't be in the master, we stop it */
408 if (!listen_in_master)
409 curproxy->state = PR_STSTOPPED;
410 }
William Lallemand88dc7c52019-04-01 11:30:01 +0200411}
412
413/* Displays workers and processes */
414static int cli_io_handler_show_proc(struct appctx *appctx)
415{
416 struct stream_interface *si = appctx->owner;
417 struct mworker_proc *child;
418 int old = 0;
419 int up = now.tv_sec - proc_self->timestamp;
420
421 if (unlikely(si_ic(si)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
422 return 1;
423
424 chunk_reset(&trash);
425
426 chunk_printf(&trash, "#%-14s %-15s %-15s %-15s %s\n", "<PID>", "<type>", "<relative PID>", "<reloads>", "<uptime>");
427 chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %dd %02dh%02dm%02ds\n", getpid(), "master", 0, proc_self->reloads, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
428
429 /* displays current processes */
430
431 chunk_appendf(&trash, "# workers\n");
432 list_for_each_entry(child, &proc_list, list) {
433 up = now.tv_sec - child->timestamp;
434
William Lallemand8f7069a2019-04-12 16:09:23 +0200435 if (!(child->options & PROC_O_TYPE_WORKER))
William Lallemand88dc7c52019-04-01 11:30:01 +0200436 continue;
437
William Lallemand45286112019-04-12 16:09:21 +0200438 if (child->options & PROC_O_LEAVING) {
William Lallemand88dc7c52019-04-01 11:30:01 +0200439 old++;
440 continue;
441 }
442 chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %dd %02dh%02dm%02ds\n", child->pid, "worker", child->relative_pid, child->reloads, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
443 }
444
445 /* displays old processes */
446
447 if (old) {
448 char *msg = NULL;
449
450 chunk_appendf(&trash, "# old workers\n");
451 list_for_each_entry(child, &proc_list, list) {
452 up = now.tv_sec - child->timestamp;
453
William Lallemand8f7069a2019-04-12 16:09:23 +0200454 if (!(child->options & PROC_O_TYPE_WORKER))
William Lallemand88dc7c52019-04-01 11:30:01 +0200455 continue;
456
William Lallemand45286112019-04-12 16:09:21 +0200457 if (child->options & PROC_O_LEAVING) {
William Lallemand88dc7c52019-04-01 11:30:01 +0200458 memprintf(&msg, "[was: %u]", child->relative_pid);
459 chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %dd %02dh%02dm%02ds\n", child->pid, "worker", msg, child->reloads, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
460 }
461 }
462 free(msg);
463 }
464
William Lallemandad53d6d2019-04-01 11:30:03 +0200465 /* displays external process */
466 chunk_appendf(&trash, "# programs\n");
467 old = 0;
468 list_for_each_entry(child, &proc_list, list) {
469 up = now.tv_sec - child->timestamp;
470
William Lallemand8f7069a2019-04-12 16:09:23 +0200471 if (!(child->options & PROC_O_TYPE_PROG))
William Lallemandad53d6d2019-04-01 11:30:03 +0200472 continue;
473
William Lallemand45286112019-04-12 16:09:21 +0200474 if (child->options & PROC_O_LEAVING) {
William Lallemandad53d6d2019-04-01 11:30:03 +0200475 old++;
476 continue;
477 }
478 chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %dd %02dh%02dm%02ds\n", child->pid, child->id, "-", child->reloads, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
479 }
480
481 if (old) {
482 chunk_appendf(&trash, "# old programs\n");
483 list_for_each_entry(child, &proc_list, list) {
484 up = now.tv_sec - child->timestamp;
485
William Lallemand8f7069a2019-04-12 16:09:23 +0200486 if (!(child->options & PROC_O_TYPE_PROG))
William Lallemandad53d6d2019-04-01 11:30:03 +0200487 continue;
488
William Lallemand45286112019-04-12 16:09:21 +0200489 if (child->options & PROC_O_LEAVING) {
William Lallemandad53d6d2019-04-01 11:30:03 +0200490 chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %dd %02dh%02dm%02ds\n", child->pid, child->id, "-", child->reloads, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
491 }
492 }
493 }
494
495
496
William Lallemand88dc7c52019-04-01 11:30:01 +0200497 if (ci_putchk(si_ic(si), &trash) == -1) {
498 si_rx_room_blk(si);
499 return 0;
500 }
501
502 /* dump complete */
503 return 1;
William Lallemand9001ce82019-04-01 11:29:57 +0200504}
William Lallemand88dc7c52019-04-01 11:30:01 +0200505
506/* reload the master process */
507static int cli_parse_reload(char **args, char *payload, struct appctx *appctx, void *private)
508{
509 if (!cli_has_level(appctx, ACCESS_LVL_OPER))
510 return 1;
511
512 mworker_reload();
513
514 return 1;
515}
516
517
518/* register cli keywords */
519static struct cli_kw_list cli_kws = {{ },{
520 { { "@<relative pid>", NULL }, "@<relative pid> : send a command to the <relative pid> process", NULL, cli_io_handler_show_proc, NULL, NULL, ACCESS_MASTER_ONLY},
521 { { "@!<pid>", NULL }, "@!<pid> : send a command to the <pid> process", cli_parse_default, NULL, NULL, NULL, ACCESS_MASTER_ONLY},
522 { { "@master", NULL }, "@master : send a command to the master process", cli_parse_default, NULL, NULL, NULL, ACCESS_MASTER_ONLY},
523 { { "show", "proc", NULL }, "show proc : show processes status", cli_parse_default, cli_io_handler_show_proc, NULL, NULL, ACCESS_MASTER_ONLY},
524 { { "reload", NULL }, "reload : reload haproxy", cli_parse_reload, NULL, NULL, NULL, ACCESS_MASTER_ONLY},
525 {{},}
526}};
527
528INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);