[manual] Update deployment process to run atomically.

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)
This commit is contained in:
Tim Abbott 2013-04-09 15:51:16 -04:00
parent f7406b9c7d
commit 1b8cf16988
3 changed files with 12 additions and 4 deletions

View File

@ -9,7 +9,7 @@ error_page 502 503 504 /static/html/5xx.html;
# Serve static files directly # Serve static files directly
location /static/ { location /static/ {
alias /home/humbug/humbug/prod-static/serve/; alias /home/humbug/humbug-deployments/current/prod-static/serve/;
error_page 404 /static/html/404.html; error_page 404 /static/html/404.html;
} }
@ -30,6 +30,6 @@ location ~ /json/get_updates|/api/v1/get_messages|/api/v1/messages/latest|/json/
# Send everything else to Django via FastCGI # Send everything else to Django via FastCGI
location / { location / {
include fastcgi_params; include fastcgi_params;
fastcgi_pass unix:/home/humbug/humbug/fastcgi-socket; fastcgi_pass unix:/home/humbug/humbug-deployments/current/fastcgi-socket;
fastcgi_split_path_info ^()(.*)$; fastcgi_split_path_info ^()(.*)$;
} }

View File

@ -16,7 +16,7 @@ WARNING = '\033[93m'
FAIL = '\033[91m' FAIL = '\033[91m'
ENDC = '\033[0m' ENDC = '\033[0m'
os.chdir("/home/humbug/humbug") os.chdir("/home/humbug/humbug-deployments/current")
# Restart the FastCGI process, which is running in a shell loop in screen. # Restart the FastCGI process, which is running in a shell loop in screen.
# TODO: real daemonization # TODO: real daemonization

View File

@ -6,6 +6,7 @@ import pylibmc
import traceback import traceback
import logging import logging
from humbug_tools import check_output from humbug_tools import check_output
import datetime
logging.basicConfig(format="%(asctime)s update-deployment: %(message)s", logging.basicConfig(format="%(asctime)s update-deployment: %(message)s",
level=logging.INFO) level=logging.INFO)
@ -33,8 +34,15 @@ subprocess.check_call(["find", ".", "-name", "*.pyc", "-delete"], stdout=open('/
logging.info("Updating static files") logging.info("Updating static files")
subprocess.check_call(["./tools/update-prod-static"]) 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...") logging.info("Restarting server...")
subprocess.check_call(["./tools/restart-server"]) subprocess.check_call(["/home/humbug/humbug-deployments/current/tools/restart-server"])
if newrev == '0000000000000000000000000000000000000000': if newrev == '0000000000000000000000000000000000000000':
# 0000000000000000000000000000000000000000 means we're deleting the ref # 0000000000000000000000000000000000000000 means we're deleting the ref