
Thanks Reza I wil give it a crack. Much appreciated, Garyc --- On Mon, 3/15/10, Reza Lotun <rlotun@gmail.com> wrote:
From: Reza Lotun <rlotun@gmail.com> Subject: Re: [Twisted-Python] Creating a daemon from my application To: "Twisted general discussion" <twisted-python@twistedmatrix.com> Date: Monday, March 15, 2010, 10:35 AM Hi,
I want to create a twisted daemon from my application: ...
You want to use twistd. See http://twistedmatrix.com/documents/current/core/howto/basics.html#auto1
The process is roughly:
1) create a myapp.tac file which essentially loads in your server and wraps it in an application 2) run something like: $ twistd -r epoll -y myapp.tac which will daemonize your server (using the epoll reactor) and write its pid to twistd.pid
A .tac file could look something like:
from twisted.application import service, internet from myapp import MyAppServer
def get_service(): """ Return a service suitable for creating an application object. """ site = MyAppServer() port = 2000 return internet.TCPServer(2000, site)
application = service.Application('MyApplicationName') # attach the service to its parent application service = get_service() service.setServiceParent(application)
Also, keep in mind you might want to use twistd in conjunction with a process runner (http://dustin.github.com/2010/02/28/running-processes.html). That is, if you're using something like Ubuntu, you probably want to run twistd using upstart.
Hope this helps.
Reza
-- Reza Lotun mobile: +44 (0)7521 310 763 email: rlotun@gmail.com work: reza@tweetdeck.com twitter: @rlotun
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python