[Twisted-Python] How to stop a twisted daemon application.
Hi, After I have run "twistd -y xxx.py" How can I stop it? I've read through twistd manual and didn't find anything about this. I have to find the process and kill it. Any better approach?
On Fri, Nov 14, 2008 at 01:49:04PM +0800, Peter Cai wrote:
After I have run "twistd -y xxx.py"
How can I stop it? I've read through twistd manual and didn't find anything about this.
I have to find the process and kill it.
When you run twistd, it should create a 'twistd.pid' file in the current directory containing the process-ID of the twistd process. I believe the standard method of stopping a background twistd is: kill $(cat twistd.pid) Also note the -n/--nodaemon command-line option which stops twistd from vanishing into the background at all. If start twistd like this: twistd -n -y xxx.py ...then you will get the log output written to the screen (rather than to a logfile) and you can kill the server with Ctrl-C instead of having to mess around with pid files.
On Fri, 14 Nov 2008 17:06:31 +1100 Tim Allen <screwtape@froup.com> wrote:
On Fri, Nov 14, 2008 at 01:49:04PM +0800, Peter Cai wrote:
How can I stop it? I've read through twistd manual and didn't find anything about this.
I have to find the process and kill it.
I believe the standard method of stopping a background twistd is:
kill $(cat twistd.pid)
I can suggest using "pkill -F twistd.pid" as a cleaner alternative. You can also define your own handlers for received signals (via signal module), to implement some custom shutdown sequence, for instance. -- Mike Kazantsev // fraggod.net
participants (3)
-
Mike Kazantsev -
Peter Cai -
Tim Allen