scripts: Add a start-server as well.

In general, `./scripts/restart-server` will already work in any
circumstance where the server is already stopped and needs to be
started.  However, it will output a couple minor warnings, and it is
not readily obvious that it *will* work correctly.

Add an alias for `restart-server` named `start-server`, for
parallelism with `stop-server`, which omits the steps of
`restart-server` which would stop the server first.
This commit is contained in:
Alex Vandiver 2021-04-16 19:02:32 +00:00 committed by Tim Abbott
parent 476524c0c1
commit ec12a6128a
6 changed files with 22 additions and 15 deletions

View File

@ -19,8 +19,13 @@ from scripts.lib.zulip_tools import (
overwrite_symlink, overwrite_symlink,
) )
action = "restart"
if not sys.argv[0].endswith("restart-server"):
action = "start"
verbing = action.title() + "ing"
logging.Formatter.converter = time.gmtime logging.Formatter.converter = time.gmtime
logging.basicConfig(format="%(asctime)s restart-server: %(message)s", level=logging.INFO) logging.basicConfig(format=f"%(asctime)s {action}-server: %(message)s", level=logging.INFO)
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("--fill-cache", action="store_true", help="Fill the memcached caches") parser.add_argument("--fill-cache", action="store_true", help="Fill the memcached caches")
@ -67,13 +72,14 @@ if len(tornado_ports) > 1:
# restarts. This also avoids behavior with restarting a whole # restarts. This also avoids behavior with restarting a whole
# supervisord group where if any individual process is slow to # supervisord group where if any individual process is slow to
# stop, the whole bundle stays stopped for an extended time. # stop, the whole bundle stays stopped for an extended time.
logging.info("Restarting Tornado process on port %s", p) logging.info("%s Tornado process on port %s", verbing, p)
subprocess.check_call(["supervisorctl", "restart", f"zulip-tornado:zulip-tornado-port-{p}"]) subprocess.check_call(["supervisorctl", action, f"zulip-tornado:zulip-tornado-port-{p}"])
else: else:
logging.info("Restarting Tornado process") logging.info("%s Tornado process", verbing)
subprocess.check_call(["supervisorctl", "restart", "zulip-tornado", "zulip-tornado:*"]) subprocess.check_call(["supervisorctl", action, "zulip-tornado", "zulip-tornado:*"])
# Restart the uWSGI and related processes via supervisorctl. # Restart the uWSGI and related processes via supervisorctl.
if action == "restart":
logging.info("Stopping workers") logging.info("Stopping workers")
subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*"]) subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*"])
logging.info("Stopping server core") logging.info("Stopping server core")
@ -90,10 +96,10 @@ if using_sso.strip() == b"True":
subprocess.check_call(["pkill", "-f", "apache2", "-u", "zulip"]) subprocess.check_call(["pkill", "-f", "apache2", "-u", "zulip"])
if os.path.exists("/etc/supervisor/conf.d/zulip/zulip_db.conf"): if os.path.exists("/etc/supervisor/conf.d/zulip/zulip_db.conf"):
subprocess.check_call(["supervisorctl", "restart", "process-fts-updates"]) subprocess.check_call(["supervisorctl", action, "process-fts-updates"])
logging.info("Done!") logging.info("Done!")
print(OKGREEN + "Zulip restarted successfully!" + ENDC) print(OKGREEN + f"Zulip {action}ed successfully!" + ENDC)
if change_symlink and "PWD" in os.environ: if change_symlink and "PWD" in os.environ:
for symlink in [last_symlink, current_symlink]: for symlink in [last_symlink, current_symlink]:

1
scripts/start-server Symbolic link
View File

@ -0,0 +1 @@
restart-server

View File

@ -52,7 +52,7 @@ cd /home/zulip/deployments/current
./scripts/stop-server ./scripts/stop-server
./manage.py convert_gitter_data gitter_data.json --output converted_gitter_data ./manage.py convert_gitter_data gitter_data.json --output converted_gitter_data
./manage.py import '' converted_gitter_data ./manage.py import '' converted_gitter_data
./scripts/restart-server ./scripts/start-server
``` ```
This could take several minutes to run, depending on how much data This could take several minutes to run, depending on how much data

View File

@ -152,7 +152,7 @@ cd /home/zulip/deployments/current
./scripts/stop-server ./scripts/stop-server
./manage.py convert_mattermost_data /home/zulip/mattermost --output /home/zulip/converted_mattermost_data ./manage.py convert_mattermost_data /home/zulip/mattermost --output /home/zulip/converted_mattermost_data
./manage.py import "" /home/zulip/converted_mattermost_data/<team-name> ./manage.py import "" /home/zulip/converted_mattermost_data/<team-name>
./scripts/restart-server ./scripts/start-server
``` ```
This could take several minutes to run, depending on how much data This could take several minutes to run, depending on how much data

View File

@ -82,7 +82,7 @@ cd /home/zulip/deployments/current
./scripts/stop-server ./scripts/stop-server
./manage.py convert_slack_data slack_data.zip --token <token> --output converted_slack_data ./manage.py convert_slack_data slack_data.zip --token <token> --output converted_slack_data
./manage.py import '' converted_slack_data ./manage.py import '' converted_slack_data
./scripts/restart-server ./scripts/start-server
``` ```
This could take several minutes to run, depending on how much data This could take several minutes to run, depending on how much data

View File

@ -7,7 +7,7 @@ cd /home/github/zulip
su zulip -c ./scripts/stop-server su zulip -c ./scripts/stop-server
./scripts/setup/upgrade-postgresql ./scripts/setup/upgrade-postgresql
supervisorctl start all su zulip -c ./scripts/start-server
echo "Upgrade of PostgreSQL complete!" echo "Upgrade of PostgreSQL complete!"
exit 0 exit 0