Dear Tim! 2009/5/18 Tim Roberts <t...@probo.com>
> Durumdara wrote: > > > > 1.) > > I wanna ask something about python services. > > ... > > Yesterday I tried to install two of pylons services. > > Interesting thing I saw. > > > > Every of the installed services are have SAME EXE without any > > information to identify, which pylons site is need to start... > > I have never seen same thing before, so I don't understand, which > > information is have PythonService.exe to know which windowsservice.py > > need to start... > > > > Is service name passed to PS.EXE by OS? > > Well, yes and no. Remember that the service script initializes itself. Ok, I know it. > > It contains all of the code necessary to register itself with the > operating system. Part of that registration process involves specifying > the exact command line that must be run to start the service. > > The service NAME isn't important at all. That's only used for filing, > so to speak. It's the command line that identifies the script to be run. One thing I don't understand that Image Path is "" (in this machine): "C:\Python25\lib\site-packages\win32\PythonService.exe" Only pointer to WindowsService script is: "PythonClass:default" = "c:\web\pylons\xxx\WindowsService.MyService" The thing I don't know if PythonService is used by Service system without any parameters then how to find this exe the PythonClass that need to be call? > > > > > I saw that in registry the service is have all data it needed. But how > > to know this ONE EXE, which service started it, and which *.py can it > > use to start? > > It's all on the command line that gets registered by the service script. I see the registration in registry/services, but only thing I don't know that how do know the PS.EXE (calling without any params ) where to look for PythonClass parameter? > > > The exact same thing is true of any long-running Python scripts. If you > have 10 different normal Python applications running, as far as the > operating system is concerned, all 10 of them are called "python.exe" > (or "pythonw.exe"). If you look in Task Manager, that's exactly what > you'll see. The personality of the application comes from the script > that is being run, but that's just a data file that gets passed to the > interpreter exe. Yes, but when I start a python file, I see infos in Process Explorer: Path: C:\Python25\python.exe Command line: "C:\Python25\python.exe" "c:\d\testdirname.py" Curr. dir: "C:\D\" When I check the service, the result is: Path: C:\Python25\lib\site-packages\win32\PythonService.exe Commad line: Cur dir: "c:\web\pylons\xxx\" > > > > > 2.) The service stopping is not correct: > > > > The Python service control handler failed. > > File "C:\Python25\lib\site-packages\win32\lib\win32serviceutil.py", > > line 791, in ServiceCtrlHandlerEx > > self.SvcStop() > > File "c:\web\pylons\xxx\WindowsService.py", line 91, in SvcStop > > sys.exit() > > <type 'exceptions.SystemExit'>: <NULL> > > > > If I changed it to sys.exit(0), or (1), I also got this message... > > Why do you think this is not correct? Because I hate if my programs are use Event Log as trash... :-( > You are only seeing that because > you are running this application within a command shell, or some other > environment where you see these log messages. Ordinarily, if this is > being run as a service in the background, you wouldn't see that message. Yes. > > > It's true that this is not the normal way to stop a service. You'll see > in that same Pylons script that they have commented out a call to assert > the "stop_event" event, which the SvcDoRun function is blocked on. > That's the normal way. SvcStop sets an event, which allows SvcDoRun to > return. When SvcDoRun returns, the service exits. However, the > sys.exit method also works. It's just that you get this little traceback When I removed the sys.exit(), it is also working without any error log Event: def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) #win32event.SetEvent(self.stop_event) self.ReportServiceStatus(win32service.SERVICE_STOPPED) #sys.exit(1) Thanks for your help: dd
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32