[Twisted-Python] How to stop a twisted daemon application.
![](https://secure.gravatar.com/avatar/58e37c9d477659b047876e02076ceabf.jpg?s=120&d=mm&r=g)
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?
![](https://secure.gravatar.com/avatar/152986af8e990c9c8b61115f298b9cb2.jpg?s=120&d=mm&r=g)
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.
![](https://secure.gravatar.com/avatar/db0d5b15da76246bed0ba3c253b5ea82.jpg?s=120&d=mm&r=g)
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