From 39286068865e26fdaa653fdb1e5732384ef45b38 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 25 Mar 2022 17:30:08 -0700 Subject: [PATCH] restart-server: Treat as a start if nothing is running. Treating the restart as a start is important in reducing the critical period during upgrades -- we call restart even when we suspect the services are stopped, because puppet has a small possibility of placing them in indeterminate state. However, restart orders the workers first, then tornado/django, which prolongs the outage. Recognize when no services are currently started, and switch to acting like a start, not a restart, which places tornado/django first. --- scripts/restart-server | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/restart-server b/scripts/restart-server index 00f5c61f6e..673e642dd9 100755 --- a/scripts/restart-server +++ b/scripts/restart-server @@ -98,6 +98,19 @@ aux_services = list_supervisor_processes(["go-camo", "smokescreen"], only_runnin if aux_services: subprocess.check_call(["supervisorctl", "start", *aux_services]) +# If none of the workers nor the application servers are running, this +# is actually a "start," not a restart, which means we will defer +# workers to later. +if ( + action == "restart" + and len( + list_supervisor_processes(workers + ["zulip-django", "zulip-tornado:*"], only_running=True) + ) + == 0 +): + action = "start" + verbing = "Starting" + def restart_or_start(service: str) -> None: our_verb = action