mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 14:21:00 +01:00
[STATS] make it possible to change a CLI connection timeout
Sometimes it helps to be able to change an interactive CLI connection timeout. Now we just have to enter "set timeout cli <value>" to do that.
This commit is contained in:
parent
2eba6aaa1b
commit
7aabd11cec
@ -7553,6 +7553,11 @@ get weight <backend>/<server>
|
||||
may be specified either by their name or by their numeric ID, prefixed with a
|
||||
dash ('#').
|
||||
|
||||
set timeout cli <delay>
|
||||
Change the CLI interface timeout for current connection. This can be useful
|
||||
during long debugging sessions where the user needs to constantly inspect
|
||||
some indicators without being disconnected. The delay is passed in seconds.
|
||||
|
||||
set weight <backend>/<server> <weight>[%]
|
||||
Change a server's weight to the value passed in argument. If the value ends
|
||||
with the '%' sign, then the new weight will be relative to the initially
|
||||
|
||||
@ -64,6 +64,7 @@ const char stats_sock_usage_msg[] =
|
||||
" show sess : report the list of current sessions\n"
|
||||
" get weight : report a server's current weight\n"
|
||||
" set weight : change a server's weight\n"
|
||||
" set timeout : change a timeout setting\n"
|
||||
"";
|
||||
|
||||
const char stats_permission_denied_msg[] =
|
||||
@ -497,7 +498,34 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
|
||||
|
||||
return 1;
|
||||
}
|
||||
else { /* not "set weight" */
|
||||
else if (strcmp(args[1], "timeout") == 0) {
|
||||
if (strcmp(args[2], "cli") == 0) {
|
||||
unsigned timeout;
|
||||
const char *res;
|
||||
|
||||
if (!*args[3]) {
|
||||
s->data_ctx.cli.msg = "Expects an integer value.\n";
|
||||
si->st0 = STAT_CLI_PRINT;
|
||||
return 1;
|
||||
}
|
||||
|
||||
res = parse_time_err(args[3], &timeout, TIME_UNIT_S);
|
||||
if (res || timeout < 1) {
|
||||
s->data_ctx.cli.msg = "Invalid timeout value.\n";
|
||||
si->st0 = STAT_CLI_PRINT;
|
||||
return 1;
|
||||
}
|
||||
|
||||
s->req->rto = s->rep->wto = 1 + MS_TO_TICKS(timeout*1000);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
s->data_ctx.cli.msg = "'set timeout' only supports 'cli'.\n";
|
||||
si->st0 = STAT_CLI_PRINT;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else { /* unknown "set" parameter */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user