summary refs log tree commit diff
path: root/synapse/app/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-07-16 15:59:36 +0100
committerGitHub <noreply@github.com>2019-07-16 15:59:36 +0100
commitc831c5b2bb95fb018756547e93fed3468a5d6b71 (patch)
treea5b3d2f7d91da0aaefdf2a4b2996c1c5243d0b7a /synapse/app/_base.py
parentReturn a different error from Invalid Password when a user is deactivated (#5... (diff)
parentRemove pointless description (diff)
downloadsynapse-c831c5b2bb95fb018756547e93fed3468a5d6b71.tar.xz
Merge pull request #5597 from matrix-org/erikj/admin_api_cmd
Create basic admin command app
Diffstat (limited to 'synapse/app/_base.py')
-rw-r--r--synapse/app/_base.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/synapse/app/_base.py b/synapse/app/_base.py
index bd285122ea..807f320b46 100644
--- a/synapse/app/_base.py
+++ b/synapse/app/_base.py
@@ -48,7 +48,7 @@ def register_sighup(func):
     _sighup_callbacks.append(func)
 
 
-def start_worker_reactor(appname, config):
+def start_worker_reactor(appname, config, run_command=reactor.run):
     """ Run the reactor in the main process
 
     Daemonizes if necessary, and then configures some resources, before starting
@@ -57,6 +57,7 @@ def start_worker_reactor(appname, config):
     Args:
         appname (str): application name which will be sent to syslog
         config (synapse.config.Config): config object
+        run_command (Callable[]): callable that actually runs the reactor
     """
 
     logger = logging.getLogger(config.worker_app)
@@ -69,11 +70,19 @@ def start_worker_reactor(appname, config):
         daemonize=config.worker_daemonize,
         print_pidfile=config.print_pidfile,
         logger=logger,
+        run_command=run_command,
     )
 
 
 def start_reactor(
-    appname, soft_file_limit, gc_thresholds, pid_file, daemonize, print_pidfile, logger
+    appname,
+    soft_file_limit,
+    gc_thresholds,
+    pid_file,
+    daemonize,
+    print_pidfile,
+    logger,
+    run_command=reactor.run,
 ):
     """ Run the reactor in the main process
 
@@ -88,6 +97,7 @@ def start_reactor(
         daemonize (bool): true to run the reactor in a background process
         print_pidfile (bool): whether to print the pid file, if daemonize is True
         logger (logging.Logger): logger instance to pass to Daemonize
+        run_command (Callable[]): callable that actually runs the reactor
     """
 
     install_dns_limiter(reactor)
@@ -97,7 +107,7 @@ def start_reactor(
         change_resource_limit(soft_file_limit)
         if gc_thresholds:
             gc.set_threshold(*gc_thresholds)
-        reactor.run()
+        run_command()
 
     # make sure that we run the reactor with the sentinel log context,
     # otherwise other PreserveLoggingContext instances will get confused