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
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)
# 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:
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).
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python