From: William Lallemand Date: Wed, 2 Feb 2022 13:13:54 +0000 (+0100) Subject: MINOR: mworker/cli: add flags in the prompt X-Git-Tag: v2.6-dev2~207 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dae12c7553930c086587f1fa377a3a83f2da72c2;p=thirdparty%2Fhaproxy.git MINOR: mworker/cli: add flags in the prompt The master CLI prompt is now able to show flags in its prompt depending on the mode used: experimental (x), expert (e), mcli-debug (d). --- diff --git a/doc/management.txt b/doc/management.txt index b9630c379b..e7f3962008 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -3675,14 +3675,14 @@ Example: expert-mode [on|off] This command activates the "expert-mode" for every worker accessed from the master CLI. Combined with "mcli-debug-mode" it also activates the command on - the master. + the master. Display the flag "e" in the master CLI prompt. See also "expert-mode" in Section 9.3 and "mcli-debug-mode" in 9.4.1. experimental-mode [on|off] This command activates the "experimental-mode" for every worker accessed from the master CLI. Combined with "mcli-debug-mode" it also activates the command on - the master. + the master. Display the flag "x" in the master CLI prompt. See also "experimental-mode" in Section 9.3 and "mcli-debug-mode" in 9.4.1. @@ -3691,7 +3691,7 @@ mcli-debug-mode [on|off] keywords that were meant for a worker CLI on the master CLI, allowing to debug the master process. Once activated, you list the new available keywords with "help". Combined with "experimental-mode" or "expert-mode" it enables even - more keywords. + more keywords. Display the flag "d" in the master CLI prompt. prompt When the prompt is enabled (via the "prompt" command), the context the CLI is @@ -3701,6 +3701,19 @@ prompt that it becomes visible that the process is still running on the previous configuration and that the new configuration is not operational. + The prompt of the master CLI is able to display several flags which are the + enable modes. "d" for mcli-debug-mode, "e" for expert-mode, "x" for + experimental-mode. + + Example: + $ socat /var/run/haproxy-master.sock - + prompt + master> expert-mode on + master(e)> experimental-mode on + master(xe)> mcli-debug-mode on + master(xed)> @1 + 95191(xed)> + reload 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 diff --git a/src/cli.c b/src/cli.c index cedf2f4aa7..ba14052c7b 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2127,10 +2127,29 @@ void pcli_write_prompt(struct stream *s) chunk_appendf(msg, "+ "); } else { if (s->pcli_next_pid == 0) - chunk_appendf(msg, "master%s> ", + chunk_appendf(msg, "master%s", (proc_self->failedreloads > 0) ? "[ReloadFailed]" : ""); else - chunk_appendf(msg, "%d> ", s->pcli_next_pid); + chunk_appendf(msg, "%d", s->pcli_next_pid); + + if (s->pcli_flags & (ACCESS_EXPERIMENTAL|ACCESS_EXPERT|ACCESS_MCLI_DEBUG)) { + chunk_appendf(msg, "("); + + if (s->pcli_flags & ACCESS_EXPERIMENTAL) + chunk_appendf(msg, "x"); + + if (s->pcli_flags & ACCESS_EXPERT) + chunk_appendf(msg, "e"); + + if (s->pcli_flags & ACCESS_MCLI_DEBUG) + chunk_appendf(msg, "d"); + + chunk_appendf(msg, ")"); + } + + chunk_appendf(msg, "> "); + + } co_inject(oc, msg->area, msg->data); }