diff --git a/scripts/upgrade-zulip b/scripts/upgrade-zulip index 8669866a70..3a6992fd57 100755 --- a/scripts/upgrade-zulip +++ b/scripts/upgrade-zulip @@ -3,7 +3,6 @@ import os import sys import subprocess import logging -import datetime import shutil import time @@ -50,25 +49,7 @@ deploy_path = subprocess.check_output([os.path.join(os.path.dirname(__file__), ' deploy_path = deploy_path.strip() os.chdir(deploy_path) -logging.info("Upgrading system packages...") -subprocess.check_call(["apt-get", "update"]) -subprocess.check_call(["apt-get", "upgrade"]) - -logging.info("Stopping Zulip...") -subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*", "zulip-django", - "zulip-tornado"], 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 server...") -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) +subprocess.check_call(["./scripts/upgrade-zulip-stage-2", deploy_path]) logging.info("Deployment complete") shutil.rmtree(LOCK_DIR) diff --git a/scripts/upgrade-zulip-stage-2 b/scripts/upgrade-zulip-stage-2 new file mode 100755 index 0000000000..ed26cc0dd4 --- /dev/null +++ b/scripts/upgrade-zulip-stage-2 @@ -0,0 +1,41 @@ +#!/usr/bin/python -u +import subprocess +import os +import sys +import logging + +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 " % (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"]) + +logging.info("Stopping Zulip...") +subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*", "zulip-django", + "zulip-tornado"], 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 server...") +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)