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.
This commit is contained in:
Alex Vandiver 2022-03-25 17:30:08 -07:00 committed by Tim Abbott
parent 3717c329b8
commit 3928606886
1 changed files with 13 additions and 0 deletions

View File

@ -98,6 +98,19 @@ aux_services = list_supervisor_processes(["go-camo", "smokescreen"], only_runnin
if aux_services: if aux_services:
subprocess.check_call(["supervisorctl", "start", *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: def restart_or_start(service: str) -> None:
our_verb = action our_verb = action