mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MEDIUM: mcli: replicate the current mode when enterin the worker process
While humans can find it convenient to enter the worker process in prompt mode, for external tools it will not be convenient to have to systematically disable it. A better approach is to replicate the master socket's mode there, since it has already been configured to suit the user: interactive, prompt and timed modes are automatically passed to the worker process. This makes the using the worker commands more natural from the master process, without having to systematically adapt it for each new connection.
This commit is contained in:
parent
c347cb73fa
commit
dc06495b71
@ -4427,7 +4427,8 @@ Example:
|
||||
interactive session on the worker process by not specifying any command
|
||||
(i.e. "@@1" on its own line). This session can be terminated either by
|
||||
closing the connection or by quitting the worker process (using the "quit"
|
||||
command).
|
||||
command). In this case, the prompt mode of the master socket (interactive,
|
||||
prompt, timed) is propagated into the worker process.
|
||||
|
||||
Examples:
|
||||
# gracefully close connections and delete a server once idle (wait max 10s)
|
||||
|
24
src/cli.c
24
src/cli.c
@ -3039,11 +3039,27 @@ int pcli_find_bidir_prefix(struct stream *s, struct channel *req, char **str, co
|
||||
/* forward what remains */
|
||||
ret = end - p;
|
||||
|
||||
/* without any command, simply enter the worker in interactive mode */
|
||||
/* without any command, simply enter the worker in interactive
|
||||
* mode or prompt mode (the same as currently used in the master).
|
||||
* The goal is to make it easy for both scripts and humans to
|
||||
* enter in the same mode in the worker as they were in the master.
|
||||
*/
|
||||
if (!ret) {
|
||||
const char *cmd = "prompt\n";
|
||||
ci_insert(req, 0, cmd, strlen(cmd));
|
||||
ret += strlen(cmd);
|
||||
const char *cmd;
|
||||
|
||||
cmd = "prompt";
|
||||
ret += ci_insert(req, ret, cmd, strlen(cmd));
|
||||
|
||||
cmd = (s->pcli_flags & PCLI_F_PROMPT) ? " p" : " i";
|
||||
ret += ci_insert(req, ret, cmd, strlen(cmd));
|
||||
|
||||
if (s->pcli_flags & PCLI_F_TIMED) {
|
||||
cmd = " timed";
|
||||
ret += ci_insert(req, ret, cmd, strlen(cmd));
|
||||
}
|
||||
|
||||
cmd = "\n";
|
||||
ret += ci_insert(req, ret, cmd, strlen(cmd));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user