problem with a python service

C

chriss

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 win32serviceutil, 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 (win32serviceutil.ServiceFramework):

_svc_name_ = 'Pampa'
_svc_display_name_ = 'Pampa Client pour WinNT'

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

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

def SvcDoRun(self):
import servicemanager
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ' Youpi ?')
)
programmePrincipal = PampaClient.PampaClient()
try :
programmePrincipal.main()
except :
shutDownThread = programmePrincipal.getShutDownThread()
shutDownThread.setService(self)
while 1:
rc = WaitForMultipleObjects((self.hWaitStop,), 0, 1000)
if rc==WAIT_OBJECT_0:
break

self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING,
5000)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ' Arret en cours')
)

shutDownThread.shutDown()
finir
while shutDownThread.isAlive():
time.sleep(2)
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING, 5000)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, ' Youpiiiii c\'est fini')
)


if __name__=='__main__':
win32serviceutil.HandleCommandLine(PampaService)


thank you in advance for your reponses,

Christophe
 

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

Forum statistics

Threads
473,836
Messages
2,569,750
Members
45,545
Latest member
rapter____0

Latest Threads

Top