mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-20 22:01:49 -04:00
REORG: cli: move "shutdown frontend" to proxy.c
Now we don't have any "shutdown" commands left in cli.c.
This commit is contained in:
parent
61b6521cbf
commit
5212d7f24c
2 changed files with 27 additions and 28 deletions
28
src/cli.c
28
src/cli.c
|
|
@ -76,7 +76,6 @@ static const char stats_sock_usage_msg[] =
|
|||
" set rate-limit : change a rate limiting value\n"
|
||||
" disable : put a server or frontend in maintenance mode\n"
|
||||
" enable : re-enable a server or frontend which is in maintenance mode\n"
|
||||
" shutdown : kill a session or a frontend (eg:to release listening ports)\n"
|
||||
"";
|
||||
|
||||
static const char stats_permission_denied_msg[] =
|
||||
|
|
@ -827,33 +826,6 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
else if (strcmp(args[0], "shutdown") == 0) {
|
||||
if (strcmp(args[1], "frontend") == 0) {
|
||||
struct proxy *px;
|
||||
|
||||
px = expect_frontend_admin(s, si, args[2]);
|
||||
if (!px)
|
||||
return 1;
|
||||
|
||||
if (px->state == PR_STSTOPPED) {
|
||||
appctx->ctx.cli.msg = "Frontend was already shut down.\n";
|
||||
appctx->st0 = STAT_CLI_PRINT;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Warning("Proxy %s stopped (FE: %lld conns, BE: %lld conns).\n",
|
||||
px->id, px->fe_counters.cum_conn, px->be_counters.cum_conn);
|
||||
send_log(px, LOG_WARNING, "Proxy %s stopped (FE: %lld conns, BE: %lld conns).\n",
|
||||
px->id, px->fe_counters.cum_conn, px->be_counters.cum_conn);
|
||||
stop_proxy(px);
|
||||
return 1;
|
||||
}
|
||||
else { /* unknown "disable" parameter */
|
||||
appctx->ctx.cli.msg = "'shutdown' only supports 'frontend', 'session' and 'sessions'.\n";
|
||||
appctx->st0 = STAT_CLI_PRINT;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else { /* not "show" nor "clear" nor "get" nor "set" nor "enable" nor "disable" */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
27
src/proxy.c
27
src/proxy.c
|
|
@ -1462,11 +1462,38 @@ static int cli_parse_set_maxconn_frontend(char **args, struct appctx *appctx, vo
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Parses the "shutdown frontend" directive, it always returns 1 */
|
||||
static int cli_parse_shutdown_frontend(char **args, struct appctx *appctx, void *private)
|
||||
{
|
||||
struct proxy *px;
|
||||
|
||||
if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
|
||||
return 1;
|
||||
|
||||
px = cli_find_frontend(appctx, args[2]);
|
||||
if (!px)
|
||||
return 1;
|
||||
|
||||
if (px->state == PR_STSTOPPED) {
|
||||
appctx->ctx.cli.msg = "Frontend was already shut down.\n";
|
||||
appctx->st0 = STAT_CLI_PRINT;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Warning("Proxy %s stopped (FE: %lld conns, BE: %lld conns).\n",
|
||||
px->id, px->fe_counters.cum_conn, px->be_counters.cum_conn);
|
||||
send_log(px, LOG_WARNING, "Proxy %s stopped (FE: %lld conns, BE: %lld conns).\n",
|
||||
px->id, px->fe_counters.cum_conn, px->be_counters.cum_conn);
|
||||
stop_proxy(px);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* register cli keywords */
|
||||
static struct cli_kw_list cli_kws = {{ },{
|
||||
{ { "set", "maxconn", "frontend", NULL }, "set maxconn frontend : change a frontend's maxconn setting", cli_parse_set_maxconn_frontend, NULL },
|
||||
{ { "show","servers", "state", NULL }, "show servers state [id]: dump volatile server information (for backend <id>)", cli_parse_show_servers, cli_io_handler_servers_state },
|
||||
{ { "show", "backend", NULL }, "show backend : list backends in the current running config", cli_parse_show_backend, cli_io_handler_show_backend },
|
||||
{ { "shutdown", "frontend", NULL }, "shutdown frontend : stop a specific frontend", cli_parse_shutdown_frontend, NULL, NULL },
|
||||
{{},}
|
||||
}};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue