Commit 8879b198 by Guba Sándor

add watchdog service

parent cc0b9eb8
...@@ -23,13 +23,14 @@ logger.info("%s loaded", __file__) ...@@ -23,13 +23,14 @@ logger.info("%s loaded", __file__)
service_name = "circle-agent" service_name = "circle-agent"
stopped = False stopped = False
def watch(): def watch():
def check_service(service_name): def check_service(service_name):
return win32serviceutil.QueryServiceStatus(service_name)[1] == 4 return win32serviceutil.QueryServiceStatus(service_name)[1] == 4
def start_service(): def start_service():
win32serviceutil.StartService(service_name) win32serviceutil.StartService(service_name)
while True: while True:
if not check_service(service_name): if not check_service(service_name):
logger.info("Service %s is not running.", service_name) logger.info("Service %s is not running.", service_name)
...@@ -38,6 +39,7 @@ def watch(): ...@@ -38,6 +39,7 @@ def watch():
return return
sleep(10) sleep(10)
class AppServerSvc (win32serviceutil.ServiceFramework): class AppServerSvc (win32serviceutil.ServiceFramework):
_svc_name_ = "circle-watchdog" _svc_name_ = "circle-watchdog"
_svc_display_name_ = "CIRCLE Watchdog" _svc_display_name_ = "CIRCLE Watchdog"
...@@ -50,6 +52,7 @@ class AppServerSvc (win32serviceutil.ServiceFramework): ...@@ -50,6 +52,7 @@ class AppServerSvc (win32serviceutil.ServiceFramework):
def SvcStop(self): def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop) win32event.SetEvent(self.hWaitStop)
global stopped
stopped = True stopped = True
logger.info("%s stopped", __file__) logger.info("%s stopped", __file__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment