[Twisted-Python] How to make twisted server run as an deamon
Bill Bumgarner
bbum at mac.com
Wed Aug 31 22:55:48 EDT 2005
On Aug 31, 2005, at 7:05 PM, EddyXu wrote:
> I need to write an deamon, by using the twisted. But it seems that it
> could not use standard thread module to make it works. Any one can
> give
> me some advice?
You will most likely want to use twistd and write a .tac file that
starts up your server. Twistd will take care of daemonizing and is
really quite nice.
--- foo.tac ---
from twisted.application import service, internet
import Foo # your server
application = service.Application("foo")
applicationService = service.IServiceCollection(application)
server = internet.TCPServer(Foo.serverPort(), Foo.serverFactory())
server.setServiceParent(applicationService)
--- end foo.tac ---
Except that it doesn't allow command line arguments to be passed
in. Bummer. Easy to fix, though, I really ought to write up a
recipe for doing so.
b.bum
More information about the Twisted-Python
mailing list