[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

windows service

Michael Chesterton

1/8/2008 12:43:00 AM

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 Chesterton
http://chesterton.i...
http://barra...



--
Michael Chesterton
http://chesterton.i...
http://barra...



1 Answer

Mike Driscoll

1/8/2008 2:11:00 PM

0

On Jan 7, 6:42 pm, Michael Chesterton <che...@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://barra...
>
> --
> Michael Chestertonhttp://chesterton.id.au/blog/http://barra...

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-wi...

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

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

Mike