[Twisted-Python] Running a twisted server as a WinNT service

Glyph Lefkowitz glyph at twistedmatrix.com
Tue Dec 11 23:49:20 EST 2001

On Sun, 2001-12-09 at 20:46, Andrew Bennetts wrote:
> This is just a quick mail to let people know what I had to do to make
> a Twisted server work as a WinNT service.

Thanks a lot, Andrew!

> First, it should be noted that I'm not using twistd or tap files, partly
> because this server has no state that needs persisting, and also because
> I'm not sure how to use them ;)

[snip service]

> And that does it.  The trickiest bit is that you need to set the log
> file to something other than stdout, otherwise it dies due to a Bad File
> Descriptor error doing logfile.flush().  Other than that, it is
> basically boilerplate code (if you're familiar with Win32 services
> written in Python).
> I wonder if there is a more integrated way to do this, though?

Well, the "integrated" way to do it would probably to be something
similar to moshe's 'tap2deb' -- a Twisted service would probably be a
.tap or .tac file which got loaded, similar to the way twistd does, and
used the 'startLogging' call to open a log file and start writing to
it.  A good default would be the doc/examples/coil.tac currently in CVS
(and in the coopweb.org "breakfast builds").

Does win32 have a standardized logging mechanism?  Twisted can log to
any file-like object, so if we could put log messages wherever winnt
expects to find them that would be good ;-)  (I vaguely recall something
called the "Event Log"?)

______      you are in a maze of twisted little applications, all
|   |_\     remarkably consistent.
|     |          -- glyph lefkowitz, glyph @ twisted matrix . com
|_____|             http://www.twistedmatrix.com/

More information about the Twisted-Python mailing list