windows service not working

Joined
Jun 18, 2008
Messages
1
Reaction score
0
I have created a simple scirpt and it is working fine when executed from command line, using the following commands
cmcservice.py install
cmcservice.py start

but when this scirpt is converted to executable using either py2exe or pyinstaller, the start function does not work and gets the following error.

cmcservice.exe start

"Error starting service: The service did not respond to the start or control request in a timely fashion."
Code of the script:
------------------
import win32serviceutil, win32service, win32event

class Service(win32serviceutil.ServiceFramework):
_svc_name_ = "mytest"
_svc_display_name_ = "mytestDisplayName"
_svc_description_ = "mytest display name"

def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)

def SvcDoRun(self):
pausetime = 60 * 100
while True:
stopsignal = win32event.WaitForSingleObject(self.hWaitStop,
pausetime)
if stopsignal == win32event.WAIT_OBJECT_0: break
self.runOneLoop()

def runOneLoop(self):
import servicemanager
servicemanager.LogInfoMsg('Running')

win32serviceutil.HandleCommandLine(Service)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top