<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Kevin Horn wrote:
<blockquote
 cite="mid:562bcc10807011526w25b5708rb6a7597ecbdb5bfe@mail.gmail.com"
 type="cite">I don't know of a portable way to do this, but...<br>
  <br>
The "stopService" method that you referenced is probably not what you
want.&nbsp; <br>
It stops a twisted service object, which you should have created in
your .tac file, but does not stop twistd.<br>
  <br>
I know diddly about how to stop and start service/daemon processes on
MacOS, but on Win32, you have a lot of options:<br>
- rewrite things to use pywin32's services support...this typically
involves starting the reactor manually, though<br>
- there's some code in the twisted svn sandbox (look under moonfallen)
that does something like this using py2exe (haven't used this though)<br>
- take your twistd command line and use "instsrv" and "srvany" to make
it run as a service (maybe)<br>
  <br>
Good luck!<br>
  <br>
Kevin Horn<br>
  <br>
  <br>
  <div class="gmail_quote">On Tue, Jul 1, 2008 at 4:53 PM, Jeff Dyke
&lt;<a moz-do-not-send="true" href="mailto:jeff.dyke@gmail.com">jeff.dyke@gmail.com</a>&gt;
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I'm
looking for a portable way to stop and start a twisted<br>
application, specifically a &nbsp;twisted.web.xmlrpc server being started<br>
with a .tac file via twistd. &nbsp;on ubuntu i can easily use the<br>
start-stop-daemon but some other developers are using mac/windows and<br>
i was looking for a nice way for all to be able to start and stop this<br>
server as they make changes to it, aside from kill/killproc that is.<br>
    <br>
I noticed that the object returned after calling internet.SSLServer<br>
server has a method called stopService, but am confused about how to<br>
use that, after starting it with twistd. &nbsp;Perhaps twistd is not the<br>
right approach for starting? &nbsp;googling around seems to bring up<br>
arguments from years past about if this behavior belongs in twisted on<br>
in the users app, but found no real solution...but may have missed the<br>
obvious.<br>
    <br>
Thanks<br>
Jeff<br>
  </blockquote>
  </div>
</blockquote>
I just parse the twistd.pid file and os.kill(pid, signal.SIGTERM).&nbsp;
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.<br>
<br>
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.<br>
<br>
<br>
</body>
</html>