Hello everybody!
I'm very bad in English but I'm going to try to explain my problem.
I have a python program and this program is a service.
chronologically :
1. I install my program like service -> it's ok
2. I start the service -> it's ok
3. I stop the service -> it's ok
4. I remove the service -> it's ok
5. I install a new version of my program like service -> it's ok
6. i try to start my new service but it don't start.
If I remove the new service and I install the old service I don't arrive
to start my old service.
If I launch my program like a process, the program start.
Is it possible that the service is badly remove? How to make to check it?
I install my service with the command: "myService. py --startup auto
--interactive install"
I remove my service with the command: "myService. py remove"
I start my service with the command: "net start pampa" (pampa is the
service name)
I stop my service with the command: "net stop pampa"
Here the code of my service:
import win32serviceuti l, win32service
import pywintypes, win32con, winerror
from win32event import *
from win32file import *
from win32pipe import *
from win32api import *
from ntsecuritycon import *
import log
import PampaClient
import time
class PampaService (win32serviceut il.ServiceFrame work):
_svc_name_ = 'Pampa'
_svc_display_na me_ = 'Pampa Client pour WinNT'
def __init__ (self,args):
win32serviceuti l.ServiceFramew ork.__init__(se lf,args)
self.hWaitStop = CreateEvent(Non e, 0, 0, None)
def SvcStop(self):
self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING)
SetEvent(self.h WaitStop)
def SvcDoRun(self):
import servicemanager
servicemanager. LogMsg(
servicemanager. EVENTLOG_INFORM ATION_TYPE,
servicemanager. PYS_SERVICE_STA RTED,
(self._svc_name _, ' Youpi ?')
)
programmePrinci pal = PampaClient.Pam paClient()
try :
programmePrinci pal.main()
except :
shutDownThread = programmePrinci pal.getShutDown Thread()
shutDownThread. setService(self )
while 1:
rc = WaitForMultiple Objects((self.h WaitStop,), 0, 1000)
if rc==WAIT_OBJECT _0:
break
self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING,
5000)
servicemanager. LogMsg(
servicemanager. EVENTLOG_INFORM ATION_TYPE,
servicemanager. PYS_SERVICE_STA RTED,
(self._svc_name _, ' Arret en cours')
)
shutDownThread. shutDown()
finir
while shutDownThread. isAlive():
time.sleep(2)
self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING, 5000)
servicemanager. LogMsg(
servicemanager. EVENTLOG_INFORM ATION_TYPE,
servicemanager. PYS_SERVICE_STO PPED,
(self._svc_name _, ' Youpiiiii c\'est fini')
)
if __name__=='__ma in__':
win32serviceuti l.HandleCommand Line(PampaServi ce)
thank you in advance for your reponses,
Christophe
I'm very bad in English but I'm going to try to explain my problem.
I have a python program and this program is a service.
chronologically :
1. I install my program like service -> it's ok
2. I start the service -> it's ok
3. I stop the service -> it's ok
4. I remove the service -> it's ok
5. I install a new version of my program like service -> it's ok
6. i try to start my new service but it don't start.
If I remove the new service and I install the old service I don't arrive
to start my old service.
If I launch my program like a process, the program start.
Is it possible that the service is badly remove? How to make to check it?
I install my service with the command: "myService. py --startup auto
--interactive install"
I remove my service with the command: "myService. py remove"
I start my service with the command: "net start pampa" (pampa is the
service name)
I stop my service with the command: "net stop pampa"
Here the code of my service:
import win32serviceuti l, win32service
import pywintypes, win32con, winerror
from win32event import *
from win32file import *
from win32pipe import *
from win32api import *
from ntsecuritycon import *
import log
import PampaClient
import time
class PampaService (win32serviceut il.ServiceFrame work):
_svc_name_ = 'Pampa'
_svc_display_na me_ = 'Pampa Client pour WinNT'
def __init__ (self,args):
win32serviceuti l.ServiceFramew ork.__init__(se lf,args)
self.hWaitStop = CreateEvent(Non e, 0, 0, None)
def SvcStop(self):
self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING)
SetEvent(self.h WaitStop)
def SvcDoRun(self):
import servicemanager
servicemanager. LogMsg(
servicemanager. EVENTLOG_INFORM ATION_TYPE,
servicemanager. PYS_SERVICE_STA RTED,
(self._svc_name _, ' Youpi ?')
)
programmePrinci pal = PampaClient.Pam paClient()
try :
programmePrinci pal.main()
except :
shutDownThread = programmePrinci pal.getShutDown Thread()
shutDownThread. setService(self )
while 1:
rc = WaitForMultiple Objects((self.h WaitStop,), 0, 1000)
if rc==WAIT_OBJECT _0:
break
self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING,
5000)
servicemanager. LogMsg(
servicemanager. EVENTLOG_INFORM ATION_TYPE,
servicemanager. PYS_SERVICE_STA RTED,
(self._svc_name _, ' Arret en cours')
)
shutDownThread. shutDown()
finir
while shutDownThread. isAlive():
time.sleep(2)
self.ReportServ iceStatus(win32 service.SERVICE _STOP_PENDING, 5000)
servicemanager. LogMsg(
servicemanager. EVENTLOG_INFORM ATION_TYPE,
servicemanager. PYS_SERVICE_STO PPED,
(self._svc_name _, ' Youpiiiii c\'est fini')
)
if __name__=='__ma in__':
win32serviceuti l.HandleCommand Line(PampaServi ce)
thank you in advance for your reponses,
Christophe