Subject: | Running under mod_perl inherits apache listening ports |
A programmer used this module to detect absence of and start searchd
from inside of Apache (mod_perl with Catalyst and RoseDB). When this
occurs, the process tree looks like this:
├─searchd(31838)───searchd(31839)─┬─{searchd}(31840)
│ ├─{searchd}(31841)
│ └─{searchd}(31842)
KVM-CentOS58[root@ivwww41 script]# lsof -P -p 31838 | grep LISTEN; echo;
lsof -P -p 31839 | grep LISTEN
searchd 31838 www 4u IPv6 852945 0t0 TCP *:81 (LISTEN)
searchd 31838 www 6u IPv6 852950 0t0 TCP *:86 (LISTEN)
searchd 31838 www 8u IPv6 852955 0t0 TCP *:444 (LISTEN)
searchd 31838 www 10u IPv6 852960 0t0 TCP *:88 (LISTEN)
searchd 31839 www 4u IPv6 852945 0t0 TCP *:81 (LISTEN)
searchd 31839 www 6u IPv6 852950 0t0 TCP *:86 (LISTEN)
searchd 31839 www 8u IPv6 852955 0t0 TCP *:444 (LISTEN)
searchd 31839 www 10u IPv6 852960 0t0 TCP *:88 (LISTEN)
searchd 31839 www 24u IPv4 853632 0t0 TCP *:9312 (LISTEN)
searchd 31839 www 25u IPv4 853633 0t0 TCP *:9306 (LISTEN)
The parent process never dies, so when you restart apache, it kills all
the running httpd processes leaving this process as the primary listener
on those ports, preventing apache from starting back up.
Stopping httpd: [ OK ]
Starting httpd: (98)Address already in use: make_sock: could not bind to
address [::]:81
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:81
no listening sockets available, shutting down
Unable to open logs
Suggestion is to detect and unbind any listening ports before the first
fork, or maybe between the two forks. I am not sure which is more
correct (if at all).