Skip to content

Commit

Permalink
scripts: Add a start-server as well.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexmv authored and timabbott committed Apr 21, 2021
1 parent 476524c commit ec12a61
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
28 changes: 17 additions & 11 deletions scripts/restart-server
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ from scripts.lib.zulip_tools import (
overwrite_symlink,
)

action = "restart"
if not sys.argv[0].endswith("restart-server"):
action = "start"
verbing = action.title() + "ing"

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.add_argument("--fill-cache", action="store_true", help="Fill the memcached caches")
Expand Down Expand Up @@ -67,17 +72,18 @@ if len(tornado_ports) > 1:
# restarts. This also avoids behavior with restarting a whole
# supervisord group where if any individual process is slow to
# stop, the whole bundle stays stopped for an extended time.
logging.info("Restarting Tornado process on port %s", p)
subprocess.check_call(["supervisorctl", "restart", f"zulip-tornado:zulip-tornado-port-{p}"])
logging.info("%s Tornado process on port %s", verbing, p)
subprocess.check_call(["supervisorctl", action, f"zulip-tornado:zulip-tornado-port-{p}"])
else:
logging.info("Restarting Tornado process")
subprocess.check_call(["supervisorctl", "restart", "zulip-tornado", "zulip-tornado:*"])
logging.info("%s Tornado process", verbing)
subprocess.check_call(["supervisorctl", action, "zulip-tornado", "zulip-tornado:*"])

# Restart the uWSGI and related processes via supervisorctl.
logging.info("Stopping workers")
subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*"])
logging.info("Stopping server core")
subprocess.check_call(["supervisorctl", "stop", *core_server_services])
if action == "restart":
logging.info("Stopping workers")
subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*"])
logging.info("Stopping server core")
subprocess.check_call(["supervisorctl", "stop", *core_server_services])

logging.info("Starting server core")
subprocess.check_call(["supervisorctl", "start", *reversed(core_server_services)])
Expand All @@ -90,10 +96,10 @@ if using_sso.strip() == b"True":
subprocess.check_call(["pkill", "-f", "apache2", "-u", "zulip"])

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!")
print(OKGREEN + "Zulip restarted successfully!" + ENDC)
print(OKGREEN + f"Zulip {action}ed successfully!" + ENDC)

if change_symlink and "PWD" in os.environ:
for symlink in [last_symlink, current_symlink]:
Expand Down
1 change: 1 addition & 0 deletions scripts/start-server
2 changes: 1 addition & 1 deletion templates/zerver/help/import-from-gitter.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ cd /home/zulip/deployments/current
./scripts/stop-server
./manage.py convert_gitter_data gitter_data.json --output 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
Expand Down
2 changes: 1 addition & 1 deletion templates/zerver/help/import-from-mattermost.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ cd /home/zulip/deployments/current
./scripts/stop-server
./manage.py convert_mattermost_data /home/zulip/mattermost --output /home/zulip/converted_mattermost_data
./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
Expand Down
2 changes: 1 addition & 1 deletion templates/zerver/help/import-from-slack.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ cd /home/zulip/deployments/current
./scripts/stop-server
./manage.py convert_slack_data slack_data.zip --token <token> --output 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
Expand Down
2 changes: 1 addition & 1 deletion tools/ci/production-upgrade-pg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd /home/github/zulip

su zulip -c ./scripts/stop-server
./scripts/setup/upgrade-postgresql
supervisorctl start all
su zulip -c ./scripts/start-server

echo "Upgrade of PostgreSQL complete!"
exit 0

0 comments on commit ec12a61

Please sign in to comment.