[Pymilter] How to shut down milter properly
Stuart D. Gathman
stuart at bmsi.com
Tue Mar 23 10:36:29 EST 2004
On Tue, 23 Mar 2004, Chris Gonnerman wrote:
> How do you shut down a Python Milter gracefully? I want a
> chance to clean up. I know it's a signals thing but I'm not even
> sure how to know which of the threads to send the signal to.
Method 1 - libmilter responds to SIGTERM. It spawns a signal thread to
listen for signals. On earlier version of Linux (RH7.3), each thread is
a separate process entry. The signal thread for libmilter can be
recognized by 'rt_sig':
set - `ps -e -o pid,wchan,cmd | grep "rt_sig ${python} bms.py"`
[ "$3" != "grep" ] && kill $1
The sysv init script provided with the RPM does this for the bms milter.
On other systems, like AIX and later Linux distros, there is only one
process entry for a multi-threaded process. Send the signal to that
process - and it goes to the signal thread(s).
Method 2 - when your milter decides to shutdown based on some other event,
it can call milter.stop. It could be listening on a socket for commands,
like RELOAD config and SHUTDOWN.
--
Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154
"Very few of our customers are going to have a pure Unix
or pure Windows environment." - Dennis Oldroyd, Microsoft Corporation
More information about the Pymilter
mailing list