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

[tor-commits] [bridgedb/develop] Add a SIGUSR1 signal handler for dumping bridge assignments.



commit 1d223ce6cd18b6c4ac71f1803f224f0a84243021
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Wed Feb 5 22:05:38 2014 +0000

    Add a SIGUSR1 signal handler for dumping bridge assignments.
    
     * FIXES #10811
---
 lib/bridgedb/Main.py |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index 24a6919..363b787 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -333,6 +333,19 @@ def _handleSIGHUP(*args):
     """Called when we receive a SIGHUP; invokes _reloadFn."""
     reactor.callLater(0, _reloadFn, *args)
 
+def _handleSIGUSR1(*args):
+    """Handler for SIGUSR1. Calls :func:`~bridgedb.runner.doDumpBridges`."""
+    logging.debug("Caught SIGUSR1 signal")
+
+    from bridgedb import runner
+
+    logging.info("Loading saved state...")
+    state = persistent.load()
+    cfg = loadConfig(state.CONFIG_FILE, state.config)
+
+    logging.info("Dumping bridge assignments to files...")
+    reactor.callLater(0, runner.doDumpBridges, cfg)
+
 
 class ProxyCategory:
     def __init__(self):
@@ -560,6 +573,7 @@ def startup(options):
     global _reloadFn
     _reloadFn = reload
     signal.signal(signal.SIGHUP, _handleSIGHUP)
+    signal.signal(signal.SIGUSR1, _handleSIGUSR1)
 
     # And actually load it to start parsing.
     reload()



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits