Two processes instead of one


#1

I have a simple configuration to balance MySql r/o servers on 1.7.5.
I have nbproc 1 in my config and understand that when I reload the config it is normal to see two processes, but I always see nbproc+1 processes alive, event with fresh startup and no connections.
I searched the docs with no luck. Any idea?
Thanks


#2

So you killall haproxy processes, no process is there, the you start it and find 2 processes although the configuration does not delclare ncproc > 1?

Then whatever method you use to start haproxy is broken (maybe a bug in the init script).


#3

It should be a problem in the script, you’re right. Starting haproxy against the config file starts only one instance.
I’m using the default start script that came with apt-get install in Ubuntu 16.04.
I’m trying to understand where the problem is, but the start action is pretty straightforward:

haproxy_start()
{
[ -d “$RUNDIR” ] || mkdir "$RUNDIR"
chown haproxy:haproxy "$RUNDIR"
chmod 2775 “$RUNDIR”

    check_haproxy_config
    start-stop-daemon --quiet --oknodo --start --pidfile "$PIDFILE" \
            --exec $HAPROXY -- -f "$CONFIG" -D -p "$PIDFILE" \
            $EXTRAOPTS || return 2
    return 0

}

Extraopts is defined as

EXTRAOPTS=

This is the log at start:

haproxy-systemd-wrapper[1596]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds

The sourced /etc/default/haproxy only contains a couple of commented lines.
The /var/run/haproxy.pid only contains last PID

Any idea?


#4

Another detail: lsof shows

haproxy 1806 haproxy 4u unix 0xffff880012e1f400 0t0 1285793 /run/haproxy/admin.sock.1804.tmp type=STREAM

1804 and 1806 are the pids fors the 2 processes. 1806 has the listening ports open, but the socket is owned by 1806 and has 1804 in the name.
1804 (other tha some libs) shows in lsof

haproxy 1804 haproxy 0r CHR 1,3 0t0 6 /dev/null
haproxy 1804 haproxy 1u unix 0xffff88003b4d4c00 0t0 1285768 type=STREAM
haproxy 1804 haproxy 2u unix 0xffff88003b4d4c00 0t0 1285768 type=STREAM
haproxy 1804 haproxy 3u a_inode 0,11 0 7104 [eventpoll]

1806 shows also the correct ports open 3306 and 33060

haproxy 1806 haproxy 0u a_inode 0,11 0 7104 [eventpoll]
haproxy 1806 haproxy 4u unix 0xffff880012e1f400 0t0 1285793 /run/haproxy/admin.sock.1804.tmp type=STREAM
haproxy 1806 haproxy 5u IPv4 1285794 0t0 TCP localhost:mysql (LISTEN)
haproxy 1806 haproxy 6u IPv4 1285795 0t0 TCP *:33060 (LISTEN)