mpaperno / spampd

SpamPD - Spam Proxy Daemon. A spam-filtering SMTP/LMTP proxy server using SpamAssassin in Perl. Since 2002.
GNU General Public License v3.0
34 stars 10 forks source link

Override Net::Server's HUP handling, just restart children. #20

Closed mpaperno closed 6 years ago

mpaperno commented 6 years ago

Possible fix for #19

trondd555 commented 6 years ago

Yes, that looks good. Does the right thing on boot, and when manually sending SIGHUP.

You can see the PIDs change as the children are restarted, and the signal is logged.

$ ps aux | grep spam
_spampd  47176  1.4  0.3 98956 13432 p1  S      8:45AM    0:00.32 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd    623  0.5  0.1 98956  5988 p1  S      8:45AM    0:00.12 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd  29365  0.0  0.1 98956  4280 p1  S      8:45AM    0:00.11 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd   8800  0.1  0.1 98956  4384 p1  S      8:45AM    0:00.06 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd  82542  0.0  0.1 98956  4416 p1  S      8:45AM    0:00.12 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd  77062  0.0  0.1 98956  4480 p1  S      8:45AM    0:00.12 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa

$ kill -HUP 47176
$ ps aux | grep spam
_spampd  47176  1.4  0.3 98956 13596 p1  S      8:45AM    0:00.57 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd  60223  0.0  0.1 98956  6128 p1  S      8:45AM    0:00.01 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd  34313  0.0  0.1 98956  4444 p1  S      8:45AM    0:00.18 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd  44661  0.0  0.1 98956  4516 p1  S      8:45AM    0:00.18 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd  87677  0.0  0.1 98956  4492 p1  S      8:45AM    0:00.05 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa
_spampd  33057  0.0  0.1 98956  4536 p1  S      8:45AM    0:00.00 /usr/bin/perl -T /usr/local/sbin/spampd --port=10025 --relayhost=127.0.0.1:10027 --tagall --pid=/var/spampd/spampd.pid --homedir=/var/spa

$ tail /var/log/maillog
Aug 21 08:45:11 obsd spampd[47176]: Process Backgrounded
Aug 21 08:45:11 obsd spampd[47176]: 2018/08/21-08:45:11 SpamPD (type Net::Server::PreForkSimple) starting! pid(47176)
Aug 21 08:45:11 obsd spampd[47176]: Binding to TCP port 10025 on host 127.0.0.1 with IPv4
Aug 21 08:45:11 obsd spampd[47176]: Setting gid to "746 746"
Aug 21 08:45:11 obsd spampd[47176]: Setting uid to "746"
Aug 21 08:45:30 obsd spampd[47176]: Sending children hup signal
mpaperno commented 6 years ago

Thanks. Yes, same results here with kill -HUP on Mint 18.3 and latest Net::Server (2.009).