summary refs log tree commit diff
diff options
context:
space:
mode:
authorJorik Schellekens <joriks@matrix.org>2019-09-06 11:15:16 +0100
committerJorik Schellekens <joriks@matrix.org>2019-09-06 11:15:16 +0100
commit38c2c5a2154a454de50602f4ab67801592cb1686 (patch)
treef8e80b2db6369d62bfb6566f1729ece5df84bf41
parentTrace how long it takes for the send trasaction to complete, including retrys... (diff)
downloadsynapse-38c2c5a2154a454de50602f4ab67801592cb1686.tar.xz
Fix exit codes
-rwxr-xr-xsynctl23
1 files changed, 21 insertions, 2 deletions
diff --git a/synctl b/synctl
index a9629cf0e8..2470de5f17 100755
--- a/synctl
+++ b/synctl
@@ -88,6 +88,7 @@ def start(configfile, daemonize=True):
             "error starting (exit code: %d); see above for logs" % e.returncode,
             colour=RED,
         )
+        raise
 
 
 def start_worker(app, configfile, worker_configfile):
@@ -102,6 +103,7 @@ def start_worker(app, configfile, worker_configfile):
             % (app, worker_configfile, e.returncode),
             colour=RED,
         )
+        raise
 
 
 def stop(pidfile, app):
@@ -292,11 +294,20 @@ def main():
             write("All processes exited; now restarting...")
 
     if action == "start" or action == "restart":
+        error = False
         if start_stop_synapse:
             # Check if synapse is already running
             if os.path.exists(pidfile) and pid_running(int(open(pidfile).read())):
                 abort("synapse.app.homeserver already running")
-            start(configfile, bool(options.daemonize))
+            try:
+                start(configfile, bool(options.daemonize))
+            except subprocess.CalledProcessError:
+                error = True
+
+        # If we're only trying to start synapse and it blew up we can safely
+        # return a non-zero exit code.
+        if not workers:
+            exit(1)
 
         for worker in workers:
             env = os.environ.copy()
@@ -307,12 +318,20 @@ def main():
             for cache_name, factor in iteritems(worker.cache_factors):
                 os.environ["SYNAPSE_CACHE_FACTOR_" + cache_name.upper()] = str(factor)
 
-            start_worker(worker.app, configfile, worker.configfile)
+            try:
+                start_worker(worker.app, configfile, worker.configfile)
+            except subprocess.CalledProcessError:
+                error = True
 
             # Reset env back to the original
             os.environ.clear()
             os.environ.update(env)
 
+        # If we only tried to start one worker and it blew up we can safely return
+        # a non-zero exit code.
+        if error and len(workers) == 1 and not start_stop_synapse:
+            exit(1)
+
 
 if __name__ == "__main__":
     main()