93 def SvcDoRun(self):
94 configfile = win32serviceutil.GetServiceCustomOption(
95 self._svc_name_, "config"
96 )
97 os.chdir(os.path.dirname(configfile))
98 self.log("Using config file %s." % configfile)
99 self.log("Logging at %s." % os.getcwd())
100 self.ReportServiceStatus(win32service.SERVICE_RUNNING)
101
103 serve_devices,
104 validate_devices,
105 DeviceServerOptions,
106 )
107
108 options = DeviceServerOptions(
109 config_fpath=configfile,
110 logging_level=logging.INFO,
111 )
112
113 try:
114 devices = validate_devices(configfile)
115 serve_devices(devices, options, self.stop_event)
116 except Exception as e:
117 servicemanager.LogErrorMsg(str(e))
118
119 sys.exit(-1)
120 self.log("Service shutdown complete.")
121 self.ReportServiceStatus(win32service.SERVICE_STOPPED)
122