mirror of https://github.com/zulip/zulip.git
55 lines
1.8 KiB
Python
Executable File
55 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python
|
|
from __future__ import print_function
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
import logging
|
|
|
|
os.environ["PYTHONUNBUFFERED"] = "y"
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
|
from zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, make_deploy_path, \
|
|
get_deployment_lock, release_deployment_lock
|
|
|
|
logging.basicConfig(format="%(asctime)s update-deployment: %(message)s",
|
|
level=logging.INFO)
|
|
|
|
if len(sys.argv) != 2:
|
|
print(FAIL + "Usage: update-deployment refname" + ENDC)
|
|
sys.exit(1)
|
|
|
|
refname = sys.argv[1]
|
|
|
|
subprocess.check_call(["mkdir", '-p',
|
|
DEPLOYMENTS_DIR,
|
|
'/home/zulip/logs'])
|
|
|
|
error_rerun_script = "%s/current/tools/update-deployment %s" % (DEPLOYMENTS_DIR, refname)
|
|
get_deployment_lock(error_rerun_script)
|
|
|
|
try:
|
|
deploy_path = make_deploy_path()
|
|
|
|
logging.info("Cloning the repository")
|
|
subprocess.check_call(["git", "clone", "-q", "-b", refname,
|
|
"git@git.zulip.net:eng/zulip.git",
|
|
deploy_path], stdout=open('/dev/null', 'w'))
|
|
|
|
os.chdir(deploy_path)
|
|
# Hack to deploy images not included in open source project
|
|
subprocess.check_call(["cp", "-a", "/etc/zulip/zulip-dropbox.png",
|
|
os.path.join(deploy_path, "static/images/logo")])
|
|
|
|
# Update static files
|
|
logging.info("Updating static files")
|
|
subprocess.check_call(["./tools/update-prod-static", "--prev-deploy",
|
|
os.path.join(DEPLOYMENTS_DIR, 'current')])
|
|
|
|
logging.info("Restarting server...")
|
|
subprocess.check_call(["./scripts/restart-server"])
|
|
|
|
logging.info("Deployment complete")
|
|
subprocess.check_call(["./scripts/purge-old-deployments"])
|
|
finally:
|
|
release_deployment_lock()
|