[Web-SIG] Daemon server management

Geoffrey Talvola gtalvola at nameconnector.com
Thu Jun 9 21:15:22 CEST 2005

Blake Winton wrote:
>> And I'm a complete blank slate when it comes to the Windows side.
> On the Windows side, I think the relevant analog would be a service.
> (Okay, on the NT side, anyways.  I'm not sure how many people would
>  want to try to run a daemon on Windows 95/98... ;)

Windows Services are definitely the way to go.

One gotcha with Windows Services is that you MUST not write to stdout/stderr
or your service will crash, because they don't exist.  The crash won't
happen right away, but as soon as you've written enough to fill up the
buffer and cause it to attempt to flush.  In practice this just means
replacing sys.stdout and sys.stderr right at the start.

Another gotcha is that I always seem to have to fiddle around with either
the current directory and/or sys.path because they seem to get set up
incorrectly when run as a service.

You can look at the service-related code in Webware for more example code.

- Geoff

More information about the Web-SIG mailing list