windows service

kyosohma at gmail.com kyosohma at gmail.com
Tue Jan 8 09:10:45 EST 2008


On Jan 7, 6:42 pm, Michael Chesterton <che... at chesterton.id.au> wrote:
> I'm trying to get a program that uses M2Crypto ThreadingSSLServer to
> run in windows as a service. I have a few problem, it doesn't listen
> on its port and I don't know how to debug it.
>
> I used the pipeservice example as a framework to get it running as a
> service
>
>          def SvcDoRun(self):
>              # Write an event log record - in debug mode we will also
>              # see this message printed.
>              servicemanager.LogMsg(
>                      servicemanager.EVENTLOG_INFORMATION_TYPE,
>                      servicemanager.PYS_SERVICE_STARTED,
>                      (self._svc_name_, '')
>                      )
>
>              daemonserver = do_daemon()
>              while 1:
>                  daemonserver.handle_request()
>
> I think I need a way to break out of that while loop when a service
> stop is sent, but not knowing what happening at that point I'm not
> sure how. It's not even listening on its port.
>
> daemonserver is
>
>      daemonserver = SSL.ThreadingSSLServer((host_ip_addr, int
> (host_port_num)), TestRequestHandler, ctx)
>
> any help?
>
> --
> Michael Chestertonhttp://chesterton.id.au/blog/http://barrang.com.au/
>
> --
> Michael Chestertonhttp://chesterton.id.au/blog/http://barrang.com.au/

Before you get it going as a service, test it as just a regular Python
script. I've created local servers using CherryPy before and been able
to test them. I recommend you do the same with yours before changing
it to a service.

If you have a firewall installed (which you should), you may need to
allow your program access through it. I've occasionally had to allow
localhost with some of the more stringent firewalls.

I found this post on creating a Windows Service for Windows 2000,
which can probably be modified for XP:
http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html

There's also this one: http://essiene.blogspot.com/2005/04/python-windows-services.html

They both sound different from the way you did it, but maybe I
misunderstood.

Mike



More information about the Python-list mailing list