restart-server: Default to running config and database checks.

If there is a syntax error in `settings.py`, `restart-server` should
provide a reasonable message about this.  It did so prior to
af08bcdb3f, becausde any invocation `./manage.py` without
`--skip-checks` will verify `settings.py`, among several other checks.
After af08bcdb3f, there are no `./manage.py` calls in most restarts,
which fa77be6e6c took further.

Add an explicit `./manage.py check` in the default case.
upgrade-zulip-stage-2 overrides this by passing `--skip-checks`, for
performance.  This also means that `upgrade-zulip-from-git` itself
picks up the same `--skip-checks` flag, since it inherits the same
flag parsing, though that is perhaps of dubious utility.
This commit is contained in:
Alex Vandiver 2022-10-13 18:35:30 -04:00 committed by Tim Abbott
parent e0838ecf93
commit f5f6a3789b
3 changed files with 11 additions and 2 deletions

View File

@ -363,6 +363,7 @@ else:
# Perform system checks -- including database checks, so we don't need
# to do them when we do migrations, below.
if not args.skip_checks:
subprocess.check_call(["./manage.py", "check", "--database", "default"], preexec_fn=su_to_zulip)
# Our next optimization is to check whether any migrations are needed
@ -465,7 +466,7 @@ else:
)
logging.info("Restarting Zulip...")
start_args = []
start_args = ["--skip-checks"]
if migrations_needed:
start_args.append("--fill-cache")
if IS_SERVER_UP:

View File

@ -645,6 +645,9 @@ def deport(netloc: str) -> str:
def start_arg_parser(action: str, add_help: bool = False) -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(add_help=add_help)
parser.add_argument("--fill-cache", action="store_true", help="Fill the memcached caches")
parser.add_argument(
"--skip-checks", action="store_true", help="Skip syntax and database checks"
)
if action == "restart":
parser.add_argument(
"--less-graceful",

View File

@ -41,6 +41,11 @@ if pwd.getpwuid(os.getuid()).pw_name != "zulip":
logging.error("Must be run as user 'zulip'.")
sys.exit(1)
if not args.skip_checks:
logging.info("Running syntax and database checks")
subprocess.check_call(["./manage.py", "check", "--database", "default"])
if args.fill_cache:
logging.info("Filling memcached caches")
subprocess.check_call(["./manage.py", "fill_memcached_caches", "--skip-checks"])