Simple TCP Server || Daemonize || Continuous

Andrew McGregor andrew at indranet.co.nz
Tue Feb 4 06:17:35 EST 2003



--On Tuesday, February 04, 2003 05:57:18 -0500 Metnetsky 
<matt at uberstats.com> wrote:

> <posted & mailed>
>
> Alex Martelli wrote:
>
>> Metnetsky wrote:
>>    ...
>>> sure I can get).  The big thing here is the transformation into a
>>> daemon. How can I make this python script fork itself away from it's
>>> parent?
>>
>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012
>>
>>
>> Alex
>
> Just about perfect, thank you.  It however raises the question: what
> needs  to be modified to allow this daemon to be started by INETD?  What
> should be  removed to make this capable of being an INETD daemon?  And
> how can I have  INETD start a python script on boot?

If it runs standalone, you don't need or want it to run under inetd.  That 
would be something different, and harder to do in python, because inetd 
passes an already open socket to servers on stdio.

Instead, all you need to do is write an initscript for it so it runs on 
boot.  The simplest thing is to start from an example from /etc/init.d, for 
instance crond, copy it and edit so it works, then add it to the correct 
runlevels using chkconfig (or by making symbolic links by hand if you don't 
have chkconfig).   If you're running some unix that doesn't have SYSV-style 
init, there will be something you can do, but you'll have to chase 
documentation in that case.

Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030205/4e14536b/attachment.sig>


More information about the Python-list mailing list