[Twisted-Python] NT Service
bob at redivi.com
Wed Mar 5 13:41:24 EST 2003
On Wednesday, Mar 5, 2003, at 13:15 America/New_York, Thad Jacobs wrote:
> Hello All,
> I've created a module that makes COM calls to our non-sql database
> win32com, and converts the results to XML format (through simple string
> concatenations). I've created a rpy script that calls this module, and
> returns the XML to the browser.
> I am currently running the HTTP server per the introduction using the
> command line.
> My question:
> How should I best deploy this application into a production
> environment? It
> will be running on an Windows 2000 server, and needs to automatically
> and run before anyone logs on in the machine. Is there a way I can
> Twisted Web as an NT service? Are there other web servers (besides
> that can be configured to run my rpy script and still allow me to
> win32com in my class module?
I'm assuming you've already RTFM'ed about win32all's win32service and
Twisted. Here's a stripped example of what has worked very well for me
for the few times I was forced to deploy under Windows:
_svc_name_ = "MyTwistedService"
_svc_display_name_ = "Example Twisted NT Service"
def __init__(self, args):
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
from twisted.python.log import startLogging
# we don't have the console, so we log somewhere
# the NT service logging facilities probably isn't the right place
#print "Check For Quit"
rv = win32event.WaitForSingleObject(self.hWaitStop, 10.0)
if not rv == win32event.WAIT_TIMEOUT:
print "Received Quit from Win32"
from twisted.internet.app import Application
app = Application("MyExampleTwistedService")
# you could call startTwisted to run as not-a-service
# or use it for cross-platform reasons
More information about the Twisted-Python