Re: init.d shell script can't stop daemon (python script)
Quoting Alexander Steinert (stony8@gmx.de):
> this might be a little OT,
Not at all.
> I wrote a (python) script that is acting like a daemon (doing something,
> sleeping for 10 seconds, doing ..., sleeping ...) and would like to
> launch and kill it from a shell script in /etc/init.d.
>
> Using start-stop-daemon seemed appropriate, but the problems is that
> no /var/run/$NAME.pid is written and /proc/<PID>/exe points to
> /usr/bin/python. Hence stopping the daemon or preventing further deamons
> from starting is not possible :(
Starting: Ethan Benson and I discussed this back in Nov 1999 and
we couldn't see how s-s-d could possibly write the correct pid in
a file because the daemon was about to fork twice.
I make my python daemons test (early) and then write (late) their
own pidfile as part of the process of daemonifying themselves.
Stopping: The --pidfile should now work of course, but I throw
in --execfile /usr/bin/python --name python --user foo
if only to document for myself what works. Those parameters are
for a daemon that is a python script starting with the header
#!/usr/bin/env python
Cheers,
--
Email: d.wright@open.ac.uk Tel: +44 1908 653 739 Fax: +44 1908 655 151
Snail: David Wright, Earth Science Dept., Milton Keynes, England, MK7 6AA
Disclaimer: These addresses are only for reaching me, and do not signify
official stationery. Views expressed here are either my own or plagiarised.
Reply to: