[Twisted-Python] How to run Twisted as a service in Windows?
Hello, I am on Windows, and I have Python 2.4 I am starting twisted with twistd.py for my wiki, but it opens a command prompt so as soon as I log off the server it is no longer working and if I restart it is the same thing. How can I run it as a service so it will always be up? I don't know much about twisted I just installed it with the MSI and follow 2 or 3 instructions from MoinMoin website (the wiki). Thanks
Don't know about a twisted way, but that's what firedaemon does: http://www.firedaemon.com/ Actually you can do this without external software with the "nt resource kit" and SRVANY.exe regards, Sebastian 2006/8/9, Mona Yazbeck <mona.yazbeck@hec.ca>:
Hello,
I am on Windows, and I have Python 2.4
I am starting twisted with twistd.py for my wiki, but it opens a command prompt so as soon as I log off the server it is no longer working and if I restart it is the same thing. How can I run it as a service so it will always be up?
I don't know much about twisted I just installed it with the MSI and follow 2 or 3 instructions from MoinMoin website (the wiki).
Thanks
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Thank you very much! I got it working with srvany.exe. Mona ----- Message d'origine ----- De : Sebastian Schulze À : Twisted general discussion Envoyé : 9 août 2006 10:20 Objet : Re: [Twisted-Python] How to run Twisted as a service in Windows? Don't know about a twisted way, but that's what firedaemon does: http://www.firedaemon.com/ Actually you can do this without external software with the "nt resource kit" and SRVANY.exe regards, Sebastian 2006/8/9, Mona Yazbeck <mona.yazbeck@hec.ca>: Hello, I am on Windows, and I have Python 2.4 I am starting twisted with twistd.py for my wiki, but it opens a command prompt so as soon as I log off the server it is no longer working and if I restart it is the same thing. How can I run it as a service so it will always be up? I don't know much about twisted I just installed it with the MSI and follow 2 or 3 instructions from MoinMoin website (the wiki). Thanks _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python ------------------------------------------------------------------------------ _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
AFAIK, twistd doesn't provide direct support for Windows Services yet (Is this planned?). But you can easily wrap a reactor,run() yourself by doing something like the following using the Win32-Python packages import win32serviceutil import win32service import win32event from twisted.internet import reactor import sys class IMSAgentBase(win32serviceutil.ServiceFramework): _svc_name_ = "myService" _svc_display_name_ = "My little Service" _svc_description_ = "My little Service" # Win2k or later _svc_deps_ = ["RpcSs"] # Start after the Network has come up... def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) reactor.callFromThread(reactor.stop) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): # initialize your services here reactor.run() win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE) def HandleCommandLine(cls): win32serviceutil.HandleCommandLine(cls) Run the above as a script. Maybe you also want to buy the following book, the docs on Python Win32 are somewhat sparse.... "Python Programming on WIN32 (Paperback)" http://www.amazon.com/gp/product/1565926218 On Wed, 2006-08-09 at 10:06 -0400, Mona Yazbeck wrote:
Hello,
I am on Windows, and I have Python 2.4
I am starting twisted with twistd.py for my wiki, but it opens a command prompt so as soon as I log off the server it is no longer working and if I restart it is the same thing. How can I run it as a service so it will always be up?
I don't know much about twisted I just installed it with the MSI and follow 2 or 3 instructions from MoinMoin website (the wiki).
Thanks
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Me again... I read the code but I just don't know what to write in SvcDoRun where it is written "initialize your services here"... the service need to be started with this line: "twistd.py --python otherfile.py", can I write that directly somewhere in there? How? Many thanks ----- Message d'origine ----- De : "Thomas Jacob" <jacob@internet24.de> À : "Twisted general discussion" <twisted-python@twistedmatrix.com> Envoyé : 9 août 2006 10:49 Objet : Re: [Twisted-Python] How to run Twisted as a service in Windows?
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
For instance, instead of the following in your .tac-File class FingerProtocol(protocol.Protocol): pass class FingerFactory(protocol.ServerFactory): protocol = FingerProtocol internet.TCPServer(1079, FingerFactory()) use this in the "initialize your services here"-Section class FingerProtocol(protocol.Protocol): pass class FingerFactory(protocol.ServerFactory): protocol = FingerProtocol reactor.listenTCP(1079, FingerFactory()) see http://twistedmatrix.com/projects/core/documentation/howto/tutorial/intro.ht... On Fri, 2006-08-11 at 11:13 -0400, Mona Yazbeck wrote:
Me again...
I read the code but I just don't know what to write in SvcDoRun where it is written "initialize your services here"... the service need to be started with this line: "twistd.py --python otherfile.py", can I write that directly somewhere in there? How?
Many thanks
participants (3)
-
Mona Yazbeck
-
Sebastian Schulze
-
Thomas Jacob