mirror of
https://github.com/zulip/zulip.git
synced 2025-10-27 10:03:56 +00:00
56 lines
2.0 KiB
Python
Executable File
56 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python2.7
|
|
#
|
|
# This script contains the actual logic for upgrading from an old
|
|
# version of Zulip to the new version. upgrade-zulip-stage-2 is
|
|
# always run from the new version of Zulip, so any bug fixes take
|
|
# effect on the very next upgrade.
|
|
from __future__ import print_function
|
|
import subprocess
|
|
import os
|
|
import sys
|
|
import logging
|
|
|
|
os.environ["PYTHONUNBUFFERED"] = "y"
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
|
from zulip_tools import FAIL, WARNING, ENDC, su_to_zulip
|
|
|
|
logging.basicConfig(format="%(asctime)s upgrade-zulip-stage-2: %(message)s",
|
|
level=logging.INFO)
|
|
|
|
if os.getuid() != 0:
|
|
logging.error("Must be run as root.")
|
|
sys.exit(1)
|
|
|
|
if len(sys.argv) != 2:
|
|
print(FAIL + "Usage: %s <deploy path>" % (sys.argv[0],) + ENDC)
|
|
sys.exit(1)
|
|
|
|
deploy_path = sys.argv[1]
|
|
|
|
logging.info("Upgrading system packages...")
|
|
subprocess.check_call(["apt-get", "update"])
|
|
subprocess.check_call(["apt-get", "upgrade"])
|
|
|
|
if os.path.exists("/etc/supervisor/conf.d/zulip_db.conf"):
|
|
subprocess.check_call(["supervisorctl", "stop", "process-fts-updates"], preexec_fn=su_to_zulip)
|
|
|
|
logging.info("Stopping Zulip...")
|
|
subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*", "zulip-django",
|
|
"zulip-tornado", "zulip-senders:*"], preexec_fn=su_to_zulip)
|
|
|
|
logging.info("Applying puppet changes...")
|
|
subprocess.check_call(["./scripts/zulip-puppet-apply", "--force"])
|
|
subprocess.check_call(["apt-get", "upgrade"])
|
|
|
|
logging.info("Applying database migrations...")
|
|
subprocess.check_call(["./manage.py", "migrate"], preexec_fn=su_to_zulip)
|
|
|
|
logging.info("Restarting Zulip...")
|
|
subprocess.check_call(["cp", "-rT", os.path.join(deploy_path, 'prod-static/serve'),
|
|
'/home/zulip/prod-static'], preexec_fn=su_to_zulip)
|
|
subprocess.check_output(["./scripts/restart-server"], preexec_fn=su_to_zulip)
|
|
|
|
if os.path.exists("/etc/supervisor/conf.d/zulip_db.conf"):
|
|
subprocess.check_call(["supervisorctl", "start", "process-fts-updates"], preexec_fn=su_to_zulip)
|