Hi List,
I've got a startup script that essentially looks like the one below #1#
(simplified..)
When configured with master-worker, the first parent process 2926 as
seen in #2# keeps running.
Doing the same without master-worker, the daemon properly detaches and
the parent exits returning possible warnings/errors..
When the second php exec line in #1# with "> /dev/null" is used instead
it does succeed.
While its running the stats page does get served by the workers..
To avoid a possible issue with polers(see my previous mail thread) ive
tried to add the -dk but still the first started parent process stays
alive..
And if terminated with a ctrl+c it stops the other master-worker
processes with it.. as can be seen in #3# (was from a different attempt
so different processid's.).
'truss' output (again with different pids..):
https://0bin.net/paste/f2p8uRU1t2ebZjkL#iJOBdPnR8mCmRrtGGkEaqsmQXfbHmQ56vQHdseh1x8U
If desired i can gater the htop/truss/console output information from a
single run..
Any other info i can provide? Or should i change my script to not expect
any console output from haproxy? In my original script the 'exec' is
called with 2 extra parameters that return the console output and exit
status..
p.s.
how should configuration/startup errors be 'handled' when using
master-worker?
A kill -1 itself wont tell if a new configured bind cannot find the
interface address to bind to? and a -c before hand wont find such a problem.
The end result that nothing is running and the error causing that
however should be 'caught' somehow for logging.?. should haproxy itself
log it to syslogs? but how will the startup script know to notify the
user of a failure?
Would it be possible when starting haproxy with -sf <PID> it would tell
if the (original?) master was successful in reloading the config /
starting new workers or how should this be done?
Currently a whole new set of master-worker processes seems to be take over..
Or am i taking the wrong approach here?
Regards,
PiBa-NL / Pieter
#1# Startup script (simplified..) haproxy.sh:
#!/bin/sh
echo "Starting haproxy."
/usr/local/bin/php -q <<ENDOFF
<?php
exec("/usr/local/sbin/haproxy -f /var/etc/haproxy/haproxy.cfg -D -dk");
// exec("/usr/local/sbin/haproxy -f /var/etc/haproxy/haproxy.cfg -D
-dk > /dev/null");
?>
ENDOFF
echo "Started haproxy..."
#2# process list:
PID PPID PGRP SESN TPGID NLWP USER PRI NI VIRT RES S CPU%
MEM% TIME+ Command
9203 1 9203 9203 0 1 root 20 0 53492 4492 S
0.0 0.4 0:00.02 `- /usr/sbin/sshd
99097 9203 99097 99097 0 1 root 20 0 78840 7608 S 0.0
0.8 0:01.04 | `- sshd: root@pts/0
99900 99097 99900 99900 2651 1 root 24 0 13084 2808 S 0.0
0.3 0:00.01 | | `- -sh
161 99900 161 99900 2651 1 root 52 0 13084 2688 S
0.0 0.3 0:00.00 | | `- /bin/sh /etc/rc.initial
3486 161 3486 99900 2651 1 root 20 0 13392 3696 S
0.0 0.4 0:00.19 | | `- /bin/tcsh
2651 3486 2651 99900 2651 1 root 21 0 13084 2660 S
0.0 0.3 0:00.00 | | `- /bin/sh
/usr/local/etc/rc.d/haproxy.sh start
2801 2651 2651 99900 2651 1 root 27 0 232M 19500 S 0.0
2.0 0:00.07 | | `- /usr/local/bin/php -q
2926 2801 2651 99900 2651 1 root 29 0 0 0 Z 0.0
0.0 0:00.01 | | `- /usr/local/sbin/haproxy -f
/var/etc/haproxy/haproxy.cfg -D -dk
3061 1 2651 99900 2651 1 root 31 0 28288 7420 S
0.0 0.7 0:00.00 `- /usr/local/sbin/haproxy -f
/var/etc/haproxy/haproxy.cfg -D -dk
3524 3061 3524 3524 0 1 root 20 0 28288 7436 S
0.0 0.7 0:00.04 | `- /usr/local/sbin/haproxy -f
/var/etc/haproxy/haproxy.cfg -D -dk
3432 3061 3432 3432 0 1 root 20 0 28288 7436 S
0.0 0.7 0:00.04 | `- /usr/local/sbin/haproxy -f
/var/etc/haproxy/haproxy.cfg -D -dk
3276 3061 3276 3276 0 1 root 20 0 28288 7436 S
0.0 0.7 0:00.04 | `- /usr/local/sbin/haproxy -f
/var/etc/haproxy/haproxy.cfg -D -dk
3103 3061 3103 3103 0 1 root 20 0 28288 7436 S
0.0 0.7 0:00.04 | `- /usr/local/sbin/haproxy -f
/var/etc/haproxy/haproxy.cfg -D -dk
#3# starting script from ssh and terminating it with Ctrl+C:
[2.4.3-DEVELOPMENT][root@pfSe.localdomain]/root:
/usr/local/etc/rc.d/haproxy.sh
Starting haproxy.
[WARNING] 324/010345 (94381) : config : missing timeouts for proxy
'HAProxyLocalStats'.
| While not properly invalid, you will certainly encounter various
problems
| with such a configuration. To fix this, please ensure that all
following
| timeouts are set to a non-zero value: 'client', 'connect', 'server'.
[WARNING] 324/010345 (94381) : Proxy 'HAProxyLocalStats': in
multi-process mode, stats will be limited to process assigned to the
current request.
[WARNING] 324/010345 (94381) : Proxy 'HAProxyLocalStats': stats admin
will not work correctly in multi-process mode.
^C[WARNING] 324/010345 (94673) : Exiting Master process...
[ALERT] 324/010345 (94673) : Current worker 95085 left with exit code 130
[ALERT] 324/010345 (94673) : Current worker 94749 left with exit code 130
[ALERT] 324/010345 (94673) : Current worker 95403 left with exit code 130
[ALERT] 324/010345 (94673) : Current worker 95698 left with exit code 130
[WARNING] 324/010345 (94673) : All workers are left. Leaving... (130)
[2.4.3-DEVELOPMENT][root@pfSe.localdomain]/root:
#4# Config:
global
master-worker
nbproc 4
listen HAProxyLocalStats
bind :2200 name localstats
mode http
stats enable
stats refresh 2
stats admin if TRUE
stats uri /
stats show-desc Test2
#5# haproxy -vv:
[2.4.3-DEVELOPMENT][root@pfSe.localdomain]/root: haproxy -vv
HA-Proxy version 1.8-rc4-cfe1466 2017/11/19
Copyright 2000-2017 Willy Tarreau <wi...@haproxy.org>
Build options :
TARGET = freebsd
CPU = generic
CC = cc
CFLAGS = -O2 -pipe -fstack-protector -fno-strict-aliasing
-fno-strict-aliasing -Wdeclaration-after-statement -fwrapv
-Wno-address-of-packed-member -Wno-null-dereference -Wno-unused-label
-DFREEBSD_PORTS
OPTIONS = USE_GETADDRINFO=1 USE_ZLIB=1 USE_CPU_AFFINITY=1
USE_ACCEPT4=1 USE_REGPARM=1 USE_OPENSSL=1 USE_LUA=1 USE_STATIC_PCRE=1
USE_PCRE_JIT=1
Default settings :
maxconn = 2000, bufsize = 16384, maxrewrite = 1024, maxpollevents = 200
Built with multi-threading support.
Built with PCRE version : 8.40 2017-01-11
Running on PCRE version : 8.40 2017-01-11
PCRE library supports JIT : yes
Encrypted password support via crypt(3): yes
Built with zlib version : 1.2.11
Running on zlib version : 1.2.11
Compression algorithms supported : identity("identity"),
deflate("deflate"), raw-deflate("deflate"), gzip("gzip")
Built with network namespace support.
Built with transparent proxy support using: IP_BINDANY IPV6_BINDANY
Built with Lua version : Lua 5.3.4
Built with OpenSSL version : OpenSSL 1.0.2k-freebsd 26 Jan 2017
Running on OpenSSL version : OpenSSL 1.0.2m-freebsd 2 Nov 2017
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports : SSLv3 TLSv1.0 TLSv1.1 TLSv1.2
Available polling systems :
kqueue : pref=300, test result OK
poll : pref=200, test result OK
select : pref=150, test result OK
Total: 3 (3 usable), will use kqueue.
Available filters :
[TRACE] trace
[COMP] compression
[SPOE] spoe