mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 23:43:43 +00:00
This requires manual steps on deploy to each of staging and prod: (1) Run the new update-deployment code to setup the initial deployment directory. (2) Restart all the programs running in screen sessions. (3) Deploy the nginx changes and restart nginx. (imported from commit 1ffe27933ee79274dc0a93d35c9938712de0ef36)
57 lines
1.8 KiB
Python
Executable File
57 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
import pylibmc
|
|
import traceback
|
|
import logging
|
|
from humbug_tools import check_output
|
|
import datetime
|
|
|
|
logging.basicConfig(format="%(asctime)s update-deployment: %(message)s",
|
|
level=logging.INFO)
|
|
|
|
# Color codes
|
|
OKBLUE = '\033[94m'
|
|
OKGREEN = '\033[92m'
|
|
WARNING = '\033[93m'
|
|
FAIL = '\033[91m'
|
|
ENDC = '\033[0m'
|
|
|
|
os.chdir("/home/humbug/humbug")
|
|
if len(sys.argv) > 1:
|
|
oldrev = sys.argv[1]
|
|
newrev = sys.argv[2]
|
|
refname = sys.argv[3]
|
|
|
|
subprocess.check_call(["git", "fetch"], stdout=open('/dev/null', 'w'))
|
|
subprocess.check_call(["git", "reset", "--hard", refname], stdout=open('/dev/null', 'w'))
|
|
|
|
# Delete all .pyc files to avoid old module files hanging around
|
|
subprocess.check_call(["find", ".", "-name", "*.pyc", "-delete"], stdout=open('/dev/null', 'w'))
|
|
|
|
# Update static files
|
|
logging.info("Updating static files")
|
|
subprocess.check_call(["./tools/update-prod-static"])
|
|
|
|
subprocess.check_call(["mkdir", '-p', '/home/humbug/humbug-deployments'])
|
|
timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
|
|
deploy_path = "/home/humbug/humbug-deployments/%s" % (timestamp,)
|
|
subprocess.check_call(["cp", '-a', '/home/humbug/humbug', deploy_path])
|
|
subprocess.check_call(["ln", '-nsf', deploy_path, "/home/humbug/humbug-deployments/current"])
|
|
|
|
logging.info("Restarting server...")
|
|
subprocess.check_call(["/home/humbug/humbug-deployments/current/tools/restart-server"])
|
|
|
|
|
|
if newrev == '0000000000000000000000000000000000000000':
|
|
# 0000000000000000000000000000000000000000 means we're deleting the ref
|
|
commits = ''
|
|
else:
|
|
commits = check_output(["git", "log", "%s..%s" % (oldrev, newrev)])
|
|
|
|
if '[schema]' in commits:
|
|
print
|
|
print FAIL + "Schema change detected! Please make the appropriate changes manually." + ENDC
|
|
print
|