[nanny] Hard stop of reactor if it's Window Service
- From: Roberto Majadas <telemaco src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nanny] Hard stop of reactor if it's Window Service
- Date: Sun, 23 Jan 2011 18:06:13 +0000 (UTC)
commit 3358127e7d970772115370d37890518f61580512
Author: Roberto Majadas <roberto majadas openshine com>
Date: Mon Nov 1 20:13:15 2010 +0100
Hard stop of reactor if it's Window Service
daemon/NannyService.py | 33 +++++++++++++++++++++++++++------
daemon/src/Daemon.py | 8 +++++++-
2 files changed, 34 insertions(+), 7 deletions(-)
---
diff --git a/daemon/NannyService.py b/daemon/NannyService.py
index 2990a72..ad26006 100644
--- a/daemon/NannyService.py
+++ b/daemon/NannyService.py
@@ -55,7 +55,10 @@ def main():
app_service.stopService)
#Reactor Run
- reactor.run()
+ if not hasattr(sys, "frozen") :
+ reactor.run()
+ else:
+ reactor.run(installSignalHandlers=0)
class NannyService (win32serviceutil.ServiceFramework):
_svc_name_ = "NannyService"
@@ -78,20 +81,38 @@ class NannyService (win32serviceutil.ServiceFramework):
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
- servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
- servicemanager.PYS_SERVICE_STARTED,
- (self._svc_name_,''))
+ import servicemanager
+
self.CheckForQuit()
pythoncom.CoInitialize()
+
sys.stdout = self.log
sys.stderr = self.log
- self.main()
+
+ #Start UP application
+ import nanny.daemon
+ application = service.Application('nanny')
+ self.daemon = nanny.daemon.Daemon(application)
+
+ app_service = service.IService(application)
+ app_service.privilegedStartService()
+ app_service.startService()
+ reactor.addSystemEventTrigger('before', 'shutdown',
+ app_service.stopService)
+
+ #Reactor Run
+ if not hasattr(sys, "frozen") :
+ reactor.run()
+ else:
+ reactor.run(installSignalHandlers=0)
def CheckForQuit(self):
retval = win32event.WaitForSingleObject(self.hWaitStop, 10)
if not retval == win32event.WAIT_TIMEOUT:
- # Received Quit from Win32
+ print " Received Quit from Win32"
+ self.daemon.win32_service_stop()
reactor.stop()
+ print "STOP"
self.log.close()
pythoncom.CoUninitialize()
diff --git a/daemon/src/Daemon.py b/daemon/src/Daemon.py
index 01b99d3..2b3daaf 100644
--- a/daemon/src/Daemon.py
+++ b/daemon/src/Daemon.py
@@ -46,4 +46,10 @@ class Daemon :
from twisted.internet import reactor
start_pyro_bus(self.quarterback)
-
+ def win32_service_stop(self):
+ self.quarterback.win32top.stop()
+ self.quarterback.firewall_filter.stop()
+ self.quarterback.filter_manager.stop()
+ self.quarterback.webcontent_filter.stop()
+ self.quarterback.session_filter.stop()
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]