From: William Lallemand <[email protected]>
Subject: CLI proxy for master process
In-Reply-To:
This patch series implements a CLI on the master process.
It's a work in progress but it is now in a usable state, so people might be
interessed in testing it.
The CLI on the master is organized this way:
* The master process implements a CLI proxy which contains:
- a listener for each -S argument on the command line
- a server using a socketpair for each worker process
- a CLI applet
* The workers have a new CLI listener which is bound on a socketpair.
This CLI is special and can be configured only from the program argument. It
was done this way so a reload with a wrong configuration won't destroy the
socket. To add a new listener to this CLI proxy, use the -S argument. You can
add some bind options to these sockets, it uses the same options as the bind
keyword but the separator is a comma instead of a space.
Example:
./haproxy -W -S /tmp/master-socket -f test1.cfg
./haproxy -W -S /tmp/master-socket,mode,700,uid,1000,gid,1000 -f test1.cfg
This CLI proxy is using a CLI analyzer which allows it to send commands on the
workers. To this purpose a routing command have been implemented, it can be
used alone to send every next commands to the same place, or as a prefix for a
command. The CLI prompt will change depending of the next default target to
send a command.
Example:
$ socat /tmp/master-socket readline
help
Unknown command. Please enter one of the following commands only :
help : this message
prompt : toggle interactive mode with prompt
quit : disconnect
@<relative pid> : send a command to the <relative pid> process
@!<pid> : send a command to the <pid> process
@master : send a command to the master process
show cli sockets : dump list of cli sockets
show proc : show processes status
master> show proc
# <PID> <type> <relative PID>
5248 master 0
5249 worker 1
5250 worker 2
5251 worker 3
master> @1
5249> show info
[...]
5249> @
master> @1 show info; @!5250 show info
[...]
Known issues that will be fixed for 1.9:
- The prompt is enabled by default, and the "prompt" command is not
parsed yet
- Might have difficulties with old processes
- multiple commands on the same line won't work because of recent
changes in process_stream
- admin/oper/user permissions are not implemented
Limitations that won't be fixed for 1.9:
- The connection is closed during a reload
- It's not a stats/commands aggregator :-)
The documentation is coming later as I'm writing a more complete doc for
the master worker.