Skip to content

Commit 9d85f64

Browse files
alexmvtimabbott
authored andcommitted
upgrade-zulip-stage-2: Pass through --skip-tornado and --less-graceful.
These restart-server arguments are useful to be able to provide to `upgrade-zulip`.
1 parent fb3368b commit 9d85f64

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

scripts/lib/upgrade-zulip-stage-2

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ from scripts.lib.zulip_tools import (
3232
get_config_file,
3333
parse_os_release,
3434
run_psql_as_postgres,
35+
start_arg_parser,
3536
su_to_zulip,
3637
)
3738

@@ -72,7 +73,9 @@ if (vendor, os_version) in UNSUPPORTED_DISTROS:
7273
# make sure we have appropriate file permissions
7374
os.umask(0o22)
7475

75-
parser = argparse.ArgumentParser()
76+
restart_parser = start_arg_parser(action="restart", add_help=False)
77+
78+
parser = argparse.ArgumentParser(parents=[restart_parser])
7679
parser.add_argument("deploy_path", metavar="deploy_path", help="Path to deployment directory")
7780
parser.add_argument("--skip-puppet", action="store_true", help="Skip doing puppet/apt upgrades.")
7881
parser.add_argument("--skip-migrations", action="store_true", help="Skip doing migrations.")
@@ -92,6 +95,15 @@ parser.add_argument(
9295
)
9396
args = parser.parse_args()
9497

98+
if not args.skip_puppet and args.less_graceful:
99+
logging.warning("Ignored --less-graceful; all upgrades without --skip-puppet are ungraceful.")
100+
101+
if not args.skip_puppet and args.skip_tornado:
102+
logging.error(
103+
"Cannot skip tornado restart unless we are skipping puppet! Omit --skip-tornado, or add --skip-puppet."
104+
)
105+
sys.exit(1)
106+
95107
deploy_path = args.deploy_path
96108
os.chdir(deploy_path)
97109

@@ -312,7 +324,12 @@ if IS_SERVER_UP or not args.skip_puppet:
312324
# Even if the server wasn't up previously, puppet might have
313325
# started it if there were supervisord configuration changes, so
314326
# we need to use restart-server if puppet ran.
315-
subprocess.check_output(["./scripts/restart-server", "--fill-cache"], preexec_fn=su_to_zulip)
327+
restart_args = ["--fill-cache"]
328+
if args.skip_tornado:
329+
restart_args.append("--skip-tornado")
330+
if args.less_graceful:
331+
restart_args.append("--less-graceful")
332+
subprocess.check_output(["./scripts/restart-server", *restart_args], preexec_fn=su_to_zulip)
316333
else:
317334
subprocess.check_output(["./scripts/start-server", "--fill-cache"], preexec_fn=su_to_zulip)
318335

0 commit comments

Comments
 (0)