Commit a634f5ce by Őry Máté

agent-winservice: add file logging

parent 035f93af
import win32serviceutil
import win32service
import win32event
import logging
import os
import servicemanager
import socket
import win32event
import win32service
import win32serviceutil
from agent import main as agent_main, reactor
logger = logging.getLogger()
fh = logging.FileHandler(
os.path.join(os.path.dirname(__file__), "agent-service.log"))
formatter = logging.Formatter(
"%(asctime)s - %(name)s [%(levelname)s] %(message)s")
fh.setFormatter(formatter)
logger.addHandler(fh)
logger.info("%s loaded", __file__)
class AppServerSvc (win32serviceutil.ServiceFramework):
_svc_name_ = "circle-agent"
......@@ -20,11 +31,13 @@ class AppServerSvc (win32serviceutil.ServiceFramework):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
reactor.stop()
logger.info("%s stopped", __file__)
def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ''))
logger.info("%s starting", __file__)
agent_main()
......
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