mirror of https://github.com/zulip/zulip.git
restart-server: Add a --only-django for rolling Django restarts.
This commit is contained in:
parent
4451db08c3
commit
44fde64c42
|
@ -691,11 +691,17 @@ def start_arg_parser(action: str, add_help: bool = False) -> argparse.ArgumentPa
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--skip-checks", action="store_true", help="Skip syntax and database checks"
|
"--skip-checks", action="store_true", help="Skip syntax and database checks"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
which_services = parser.add_mutually_exclusive_group()
|
||||||
|
which_services.add_argument(
|
||||||
"--skip-client-reloads",
|
"--skip-client-reloads",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Do not send reload events to web clients",
|
help="Do not send reload events to web clients",
|
||||||
)
|
)
|
||||||
|
which_services.add_argument(
|
||||||
|
"--only-django",
|
||||||
|
action="store_true",
|
||||||
|
help=f"Only {action} Django (not Tornado or workers)",
|
||||||
|
)
|
||||||
if action == "restart":
|
if action == "restart":
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--less-graceful",
|
"--less-graceful",
|
||||||
|
|
|
@ -122,23 +122,21 @@ 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 args.only_django:
|
||||||
|
workers = []
|
||||||
|
check_services = ["zulip-django"]
|
||||||
|
else:
|
||||||
|
check_services = [*workers, "zulip-django", "zulip-tornado:*"]
|
||||||
|
|
||||||
# If none of the workers nor the application servers are running, this
|
# If none of the workers nor the application servers are running, this
|
||||||
# is actually a "start," not a restart, which means we will defer
|
# is actually a "start," not a restart, which means we will defer
|
||||||
# workers to later.
|
# workers to later.
|
||||||
if (
|
running_services = list_supervisor_processes(check_services, only_running=True)
|
||||||
action == "restart"
|
if action == "restart" and len(running_services) == 0:
|
||||||
and len(
|
|
||||||
list_supervisor_processes([*workers, "zulip-django", "zulip-tornado:*"], only_running=True)
|
|
||||||
)
|
|
||||||
== 0
|
|
||||||
):
|
|
||||||
action = "start"
|
action = "start"
|
||||||
verbing = "Starting"
|
verbing = "Starting"
|
||||||
elif action == "start":
|
elif action == "start":
|
||||||
existing_services = list_supervisor_processes([*workers, "zulip-django", "zulip-tornado:*"])
|
existing_services = list_supervisor_processes(check_services)
|
||||||
running_services = list_supervisor_processes(
|
|
||||||
[*workers, "zulip-django", "zulip-tornado:*"], only_running=True
|
|
||||||
)
|
|
||||||
if existing_services == running_services:
|
if existing_services == running_services:
|
||||||
logging.info("Zulip is already started; nothing to do!")
|
logging.info("Zulip is already started; nothing to do!")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -172,25 +170,26 @@ if action == "restart" and len(workers) > 0:
|
||||||
restart_or_start(worker)
|
restart_or_start(worker)
|
||||||
|
|
||||||
if has_application_server():
|
if has_application_server():
|
||||||
# Next, we restart the Tornado processes sequentially, in order to
|
if not args.only_django:
|
||||||
# minimize downtime of the tornado service caused by too many
|
# Next, we restart the Tornado processes sequentially, in order to
|
||||||
# Python processes restarting at the same time, resulting in each
|
# minimize downtime of the tornado service caused by too many
|
||||||
# receiving insufficient priority. This is important, because
|
# Python processes restarting at the same time, resulting in each
|
||||||
# Tornado being unavailable for too long is the main source of
|
# receiving insufficient priority. This is important, because
|
||||||
# user-visible downtime when we restart a Zulip server. We do
|
# Tornado being unavailable for too long is the main source of
|
||||||
# this before restarting Django, in case there are new event types
|
# user-visible downtime when we restart a Zulip server. We do
|
||||||
# which it will need to know how to deal with.
|
# this before restarting Django, in case there are new event types
|
||||||
if len(tornado_ports) > 1:
|
# which it will need to know how to deal with.
|
||||||
for p in tornado_ports:
|
if len(tornado_ports) > 1:
|
||||||
# Restart Tornado processes individually for a better rate of
|
for p in tornado_ports:
|
||||||
# restarts. This also avoids behavior with restarting a whole
|
# Restart Tornado processes individually for a better rate of
|
||||||
# supervisord group where if any individual process is slow to
|
# restarts. This also avoids behavior with restarting a whole
|
||||||
# stop, the whole bundle stays stopped for an extended time.
|
# supervisord group where if any individual process is slow to
|
||||||
logging.info("%s Tornado process on port %s", verbing, p)
|
# stop, the whole bundle stays stopped for an extended time.
|
||||||
restart_or_start(f"zulip-tornado:zulip-tornado-port-{p}")
|
logging.info("%s Tornado process on port %s", verbing, p)
|
||||||
else:
|
restart_or_start(f"zulip-tornado:zulip-tornado-port-{p}")
|
||||||
logging.info("%s Tornado process", verbing)
|
else:
|
||||||
restart_or_start("zulip-tornado:*")
|
logging.info("%s Tornado process", verbing)
|
||||||
|
restart_or_start("zulip-tornado:*")
|
||||||
|
|
||||||
# Finally, restart the Django uWSGI processes.
|
# Finally, restart the Django uWSGI processes.
|
||||||
if (
|
if (
|
||||||
|
@ -235,13 +234,13 @@ if has_application_server():
|
||||||
# If we were doing this non-gracefully, or starting as opposed to
|
# If we were doing this non-gracefully, or starting as opposed to
|
||||||
# restarting, we need to turn the workers (back) on. There's no
|
# restarting, we need to turn the workers (back) on. There's no
|
||||||
# advantage to doing this not-all-at-once.
|
# advantage to doing this not-all-at-once.
|
||||||
if action == "start" or args.less_graceful:
|
if (action == "start" or args.less_graceful) and not args.only_django:
|
||||||
workers = list_supervisor_processes(workers, only_running=False)
|
workers = list_supervisor_processes(workers, only_running=False)
|
||||||
if workers:
|
if workers:
|
||||||
logging.info("Starting workers")
|
logging.info("Starting workers")
|
||||||
subprocess.check_call(["supervisorctl", "start", *workers])
|
subprocess.check_call(["supervisorctl", "start", *workers])
|
||||||
|
|
||||||
if has_application_server() and not args.skip_client_reloads:
|
if has_application_server() and not args.skip_client_reloads and not args.only_django:
|
||||||
# All of the servers have been (re)started; now enqueue events in
|
# All of the servers have been (re)started; now enqueue events in
|
||||||
# the Tornado servers to tell clients to reload.
|
# the Tornado servers to tell clients to reload.
|
||||||
subprocess.check_call(["./scripts/reload-clients"])
|
subprocess.check_call(["./scripts/reload-clients"])
|
||||||
|
|
Loading…
Reference in New Issue