Hi, maintainers,

I would like to discuss the specifications of pidfile.
Please let me know your opinion when you have time.

I understand the specifications of pidfile as:

 - in daemon mode

   Pid of workers are written to pidfile for the number of nbproc

 - in master-worker mode

   Only one pid of master is written to pidfile

If multiple haproxy are started under these specifications, the behavior as:

 - in daemon mode

   Run  /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid,
   then /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid.

    - The pidfile created by the former is overwritten by the latter.
    - The contents of the pidfile are pids for the latter nbproc.
    - The haproxy processes have been started for both the former and the 
latter.

  The results are as follows:

    ~]# grep nbproc /etc/haproxy/haproxy.cfg
        nbproc      5
    ~]# /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    ~]# ps -ef | grep -w haproxy | grep -vw grep
    haproxy    17954       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17955       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17956       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17957       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17958       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    ~]# cat /run/haproxy.pid
    17954
    17955
    17956
    17957
    17958
    ~]# /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    ~]# ps -ef | grep -w haproxy | grep -vw grep
    haproxy    17954       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17955       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17956       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17957       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17958       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17972       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17973       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17974       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17975       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17976       1  0 00:50 ?        00:00:00 /usr/sbin/haproxy -D -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    ~]# cat /run/haproxy.pid
    17972
    17973
    17974
    17975
    17976
    ~]#

 - in master-worker mode

   Run  /usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid,
   then /usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid.

    - The pidfile created by the former is overwritten by the latter.
    - The content of the pidfile has only one pid of the latter's master
    - The haproxy processes have been started for both the former and the 
latter.

  The results are as follows:

    ~]# grep nbproc /etc/haproxy/haproxy.cfg
        nbproc      5
    ~]# /usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    ~]# ps -ef | grep -w haproxy | grep -vw grep
    root       17991       1  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17992   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17993   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17994   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17995   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17996   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    ~]# cat /run/haproxy.pid
    17991
    ~]# /usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    ~]# ps -ef | grep -w haproxy | grep -vw grep
    root       17991       1  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17992   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17993   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17994   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17995   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    17996   17991  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    root       18002       1  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    18003   18002  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    18004   18002  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    18005   18002  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    18006   18002  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    haproxy    18007   18002  0 00:54 ?        00:00:00 /usr/sbin/haproxy -W -f 
/etc/haproxy/haproxy.cfg -p /run/haproxy.pid
    ~]# cat /run/haproxy.pid
    18002
    ~]#

What should the pidfile specification be?

 - If we enable the former and latter haproxy, we should include both pids in 
the pidfile.
 - If we enable only the former or latter pid to the pidfile, we should disable 
multiple startup of haproxy.
   For example, 
    - if the former is running, the latter cannot start.
    - when the latter is started, the former is forcibly stopped.

Please let me know your opinion.

Best regards,
MIZUTA Takeshi

Reply via email to