[Twisted-Python] stopping daemon started via twistd
jeff.dyke at gmail.com
Thu Jul 3 07:46:55 EDT 2008
thought you might say that, i had started down that path...perhaps i'm
headed back, thanks.
On Wed, Jul 2, 2008 at 9:36 AM, Curt <curtferguson at cfl.rr.com> wrote:
> Jeff Dyke wrote:
> 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
> def handle_shutdown(self, user, *args):
> if user.account.access is not AllAccess.Owner:
> pid = int(file('twistd.pid', mode = 'r').readline())
> os.kill(pid, signal.SIGUSR1)
> user.socket.sendToClient('Normal shutdown, rotating
> os.kill(pid, signal.SIGTERM)
> Here's my handle_shutdown method, slightly abbreviated.
> Just call this the same way you give the app any other input....IE: if it is
> a web app, put an admin control clickie somewhere that activates it. If it
> is a custom client, put a control in that, if it is a direct TCP app
> (telnet) make the command parser call it when the user enters the proper
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
More information about the Twisted-Python