![]() Where my_script.py is the boilerplate script above, modified to invoke your application script or code in the main() function. For Python you can do this, which creates the service in one go: nssm install MyServiceName c:\python27\python.exe c:\temp\myscript.py This allows you to install a service and provides a GUI for configuring the command line the service executes. The best solution for this at the moment appears to be to use Non-sucking Service Manager. You will also need to install this as a service. Your application code, probably invoking a separate script, would go in the main() function. Win32serviceutil.HandleCommandLine(AppServerSvc) Servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, Self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) Self.hWaitStop = win32event.CreateEvent(None,0,0,None) Win32serviceutil.ServiceFramework._init_(self,args) import win32serviceutilĬlass AppServerSvc (win32serviceutil.ServiceFramework): Depending on how you installed Python, you might need to install this separately. The modules used in this example are part of pywin32 (Python for Windows extensions). A Python script that can be run as a service
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |