9.4. Master CLI

  1. The master CLI is a socket bound to the master process in master-worker mode.
  2. This CLI gives access to the unix socket commands in every running or leaving
  3. processes and allows a basic supervision of those processes.
  4.  
  5. The master CLI is configurable only from the haproxy program arguments with
  6. the -S option. This option also takes bind options separated by commas.

Example:

  1. # haproxy -W -S 127.0.0.1:1234 -f test1.cfg
  2. # haproxy -Ws -S /tmp/master-socket,uid,1000,gid,1000,mode,600 -f test1.cfg
  3. # haproxy -W -S /tmp/master-socket,level,user -f test1.cfg
  1. The master CLI introduces a new 'show proc' command to surpervise the
  2. processes:

Example:

  1. $ echo 'show proc' | socat /var/run/haproxy-master.sock -
  2. #<PID> <type> <relative PID> <reloads> <uptime> <version>
  3. 1162 master 0 5 0d00h02m07s 2.0-dev7-0124c9-7
  4. # workers
  5. 1271 worker 1 0 0d00h00m00s 2.0-dev7-0124c9-7
  6. 1272 worker 2 0 0d00h00m00s 2.0-dev7-0124c9-7
  7. # old workers
  8. 1233 worker [was: 1] 3 0d00h00m43s 2.0-dev3-6019f6-289
  1. In this example, the master has been reloaded 5 times but one of the old
  2. worker is still running and survived 3 reloads. You could access the CLI of
  3. this worker to understand what's going on.
  4.  
  5. When the prompt is enabled (via the "prompt" command), the context the CLI is
  6. working on is displayed in the prompt. The master is identified by the "master"
  7. string, and other processes are identified with their PID. In case the last
  8. reload failed, the master prompt will be changed to "master[ReloadFailed]>" so
  9. that it becomes visible that the process is still running on the previous
  10. configuration and that the new configuration is not operational.
  11.  
  12. The master CLI uses a special prefix notation to access the multiple
  13. processes. This notation is easily identifiable as it begins by a @.
  14.  
  15. A @ prefix can be followed by a relative process number or by an exclamation
  16. point and a PID. (e.g. @1 or @!1271). A @ alone could be use to specify the
  17. master. Leaving processes are only accessible with the PID as relative process
  18. number are only usable with the current processes.

Examples:

  1. $ socat /var/run/haproxy-master.sock readline
  2. prompt
  3. master> @1 show info; @2 show info
  4. [...]
  5. Process_num: 1
  6. Pid: 1271
  7. [...]
  8. Process_num: 2
  9. Pid: 1272
  10. [...]
  11. master>
  12. $ echo &#x27;@!1271 show info; @!1272 show info' | socat /var/run/haproxy-master.sock -
  13. [...]
  1. A prefix could be use as a command, which will send every next commands to
  2. the specified process.

Examples:

  1. $ socat /var/run/haproxy-master.sock readline
  2. prompt
  3. master> @1
  4. 1271> show info
  5. [...]
  6. 1271> show stat
  7. [...]
  8. 1271> @
  9. master>
  10. $ echo &#x27;@1; show info; show stat; @2; show info; show stat' | socat /var/run/haproxy-master.sock -
  11. [...]
  1. You can also reload the HAProxy master process with the "reload" command which
  2. does the same as a `kill -USR2` on the master process, provided that the user
  3. has at least "operator" or "admin" privileges.

Example:

  1. $ echo "reload" | socat /var/run/haproxy-master.sock
  1. Note that a reload will close the connection to the master CLI.