Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python run as service windows

import win32serviceutil
import win32service
import win32event
import servicemanager
import socket


class AppServerSvc (win32serviceutil.ServiceFramework):
    _svc_name_ = "TestService"
    _svc_display_name_ = "Test Service"

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

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

    def SvcDoRun(self):
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STARTED,
                              (self._svc_name_,''))
        self.main()

    def main(self):
        pass
      #your code here

if __name__ == '__main__':
    win32serviceutil.HandleCommandLine(AppServerSvc)
    
Comment

PREVIOUS NEXT
Code Example
Python :: median absolute deviation scipy 
Python :: package for downloading from youtybe for python 
Python :: train,test,dev python 
Python :: how to invert a list in python 
Python :: sort defaultdict by value 
Python :: print 2d array in python 
Python :: discord get username slash command 
Python :: dataframe row 
Python :: how to format integer to two digit in python 
Python :: python version kali linux 
Python :: python random word 
Python :: python selenium full screen 
Python :: python yaml load_all 
Python :: pandas.core.series.series to dataframe 
Python :: python counter least common 
Python :: get biggest value in array python3 
Python :: how to make a pythoon turtle follow another? 
Python :: python create virtualenv 
Python :: plt.suptitle position 
Python :: drf default pagination 
Python :: python convert string to date 
Python :: python catch sigterm 
Python :: remove first 2 rows in pandas 
Python :: how to iterate pyspark dataframe 
Python :: python style console output 
Python :: import matplotlib plt 
Python :: change working directory python 
Python :: python check if exe is running 
Python :: Concat and Append DFs Python 
Python :: ipywidegtes dropdown 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =