[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r12813: implement reload-bridges-on-sighup. (in bridgedb/trunk: . lib/bridgedb)



Author: nickm
Date: 2007-12-14 16:00:50 -0500 (Fri, 14 Dec 2007)
New Revision: 12813

Modified:
   bridgedb/trunk/
   bridgedb/trunk/lib/bridgedb/Main.py
   bridgedb/trunk/lib/bridgedb/Server.py
Log:
 r17152@catbus:  nickm | 2007-12-14 16:00:08 -0500
 implement reload-bridges-on-sighup.



Property changes on: bridgedb/trunk
___________________________________________________________________
 svk:merge ticket from /bridgedb/trunk [r17152] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: bridgedb/trunk/lib/bridgedb/Main.py
===================================================================
--- bridgedb/trunk/lib/bridgedb/Main.py	2007-12-14 20:32:50 UTC (rev 12812)
+++ bridgedb/trunk/lib/bridgedb/Main.py	2007-12-14 21:00:50 UTC (rev 12813)
@@ -3,10 +3,12 @@
 # See LICENSE for licensing informatino
 
 import anydbm
-
 import os
+import signal
 import sys
 
+from twisted.internet import reactor
+
 import bridgedb.Bridges as Bridges
 import bridgedb.Dist as Dist
 import bridgedb.Time as Time
@@ -87,6 +89,10 @@
             splitter.insert(bridge)
         f.close()
 
+_reloadFn = None
+def _handleSIGHUP(*args):
+    reactor.callLater(0, _reloadFn)
+
 def startup(cfg):
     cfg.BRIDGE_FILES = [ os.path.expanduser(fn) for fn in cfg.BRIDGE_FILES ]
     for key in ("RUN_IN_DIR", "DB_FILE", "DB_LOG_FILE", "MASTER_KEY_FILE",
@@ -152,6 +158,13 @@
     if cfg.EMAIL_DIST and cfg.EMAIL_SHARE:
         Server.addSMTPServer(cfg, emailDistributor, emailSchedule)
 
+    def reload():
+        load(cfg, splitter)
+
+    global _reloadFn
+    _reloadFn = reload
+    signal.signal(signal.SIGHUP, _handleSIGHUP)
+
     try:
         print "Starting reactors."
         Server.runServers()

Modified: bridgedb/trunk/lib/bridgedb/Server.py
===================================================================
--- bridgedb/trunk/lib/bridgedb/Server.py	2007-12-14 20:32:50 UTC (rev 12812)
+++ bridgedb/trunk/lib/bridgedb/Server.py	2007-12-14 21:00:50 UTC (rev 12813)
@@ -177,7 +177,7 @@
         if user.dest.local != self.ctx.username:
             raise twisted.mail.smtp.SMTPBadRcpt(user)
         return lambda: MailMessage(self.ctx)
-    
+
 class MailFactory(twisted.mail.smtp.SMTPFactory):
     def __init__(self, *a, **kw):
         twisted.mail.smtp.SMTPFactory.__init__(self, *a, **kw)