[Twisted-Python] stopping daemon started via twistd

Jeff Dyke jeff.dyke at gmail.com
Wed Jul 2 08:39:33 EDT 2008


On Tue, Jul 1, 2008 at 7:09 PM, Curt <curtferguson at cfl.rr.com> wrote:
> Kevin Horn wrote:
>
> I don't know of a portable way to do this, but...
>
> The "stopService" method that you referenced is probably not what you want.
> It stops a twisted service object, which you should have created in your
> .tac file, but does not stop twistd.
>
> I know diddly about how to stop and start service/daemon processes on MacOS,
> but on Win32, you have a lot of options:
> - rewrite things to use pywin32's services support...this typically involves
> starting the reactor manually, though
> - there's some code in the twisted svn sandbox (look under moonfallen) that
> does something like this using py2exe (haven't used this though)
> - take your twistd command line and use "instsrv" and "srvany" to make it
> run as a service (maybe)
>
> Good luck!
>
> Kevin Horn
>
>
> On Tue, Jul 1, 2008 at 4:53 PM, Jeff Dyke <jeff.dyke at gmail.com> wrote:
>>
>> I'm looking for a portable way to stop and start a twisted
>> application, specifically a  twisted.web.xmlrpc server being started
>> with a .tac file via twistd.  on ubuntu i can easily use the
>> start-stop-daemon but some other developers are using mac/windows and
>> i was looking for a nice way for all to be able to start and stop this
>> server as they make changes to it, aside from kill/killproc that is.
>>
>> I noticed that the object returned after calling internet.SSLServer
>> server has a method called stopService, but am confused about how to
>> use that, after starting it with twistd.  Perhaps twistd is not the
>> right approach for starting?  googling around seems to bring up
>> arguments from years past about if this behavior belongs in twisted on
>> in the users app, but found no real solution...but may have missed the
>> obvious.
>>
>> Thanks
>> Jeff
>
> I just parse the twistd.pid file and os.kill(pid, signal.SIGTERM).  This
> does a 'nice' shutdown, each service that the twistd daemon is running will
> call it's stopService method for cleanup and shut down in an orderly manner.
makes sense.

>
> PS. the signal above is in a shutdown command in the app that does any
> necessary app level clean-up first, although I guess you could put that
> clean-up in your service's stopService method too.

what do you mean is in a shutdown command in the app, how do you tell
the app to execute the shutdown command containing os.kill?   If i can
figure all this out and more, i'd love to fulfill that feature
request.

thanks

>
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>




More information about the Twisted-Python mailing list