Creating and Installing Python NT Services
kay c
kcollins15 at cfl.rr.com
Wed Feb 26 16:13:51 EST 2003
Hi,
I have a couple questions regarding Python and NT Services.
I zipped up the python directory from a machine that has python
installed using the wise install, default install. I unzipped so the
python directory so it looks exactly like the one it came from. I
placed all the python dll's in the path and tried to register
PythonService.exe, this failed.
QUESTION 1: Is this impossible. I am attempting to do this because
wise does not offer a solution of a silent install to a specified
directory.
I created a simple Python NT Service using examples I found from
postings for this group.
I register the PythonService.exe and then install the service ( On
machine that has installed python using wise install).
The Service simply calls a python exe that is located on the local
machine. I can successfully install this Service on windows 2000
professional but when I use the install option against my service
script on windows 2000 Server it doesn't install; it opens the .py
script in notepad with no errors in the cmd shell.
>jini_service.py install
QUESTION 2. Any idea what could be happening?
I successfully install the NT Service on my 2000 profession machine
and start it through the start command, the executable executes as
expected,
>jini_service.py start
however if I look at the Services GUI found in Settings\Control
Panel\Administrative tools the Service status is blank. The Event
Viewer information log reports the status as started.
When I stop the service it tells me the service isn't start; Error
stopping service: The service has not been started. (1062), however I
know my executable use executed.
QUESTION 3. Any idea what I am missing?
******* code******
class JiniService(win32serviceutil.ServiceFramework):
_svc_name_="JINI"
_svc_display_name_="JINI Server"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
def SvcDoRun(self):
self.Start_JiniService()
import servicemanager
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_,''))
def SvcStop(self):
import servicemanager
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_,''))
try:
self.Stop_JiniService()
except:
pass
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def Start_JiniService(self):
si=win32process.STARTUPINFO()
result=win32process.CreateProcess(
None,
'C:\\WINNT\\NetBoss\\5.0\\bin\\jini\\start_jini.exe',
None,
None,
0,
0,
None,
None,
si)
self.hSched=result[0]
def Stop_JiniService(self):
win32process.TerminateProcess(self.hSched, 0)
if __name__=='__main__':
win32serviceutil.HandleCommandLine(JiniService)
Thank You,
K
More information about the Python-list
mailing list