enterprise: Split upgrade-zulip in two for better future-proofing

(imported from commit 808d8d68a6e799aa2962eec90c0953db3c94cfa4)
This commit is contained in:
Zev Benjamin 2013-11-13 16:05:36 -05:00
parent e8c104012b
commit 9addde74ec
2 changed files with 42 additions and 20 deletions

View File

@ -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)

41
scripts/upgrade-zulip-stage-2 Executable file
View File

@ -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 <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"])
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)