From 5c450afd2dc1b2eb7d8e74f4e18e6cd1e36b7af5 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 8 Nov 2013 16:41:12 -0500 Subject: [PATCH] Split out unpack-zulip from the upgrade script. (imported from commit e41a8ad01c3042c7d877fb3aa17f9617dc2b0121) --- scripts/unpack-zulip | 26 ++++++++++++++++++++++++++ scripts/upgrade-zulip | 13 ++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) create mode 100755 scripts/unpack-zulip diff --git a/scripts/unpack-zulip b/scripts/unpack-zulip new file mode 100755 index 0000000000..4215d9bd21 --- /dev/null +++ b/scripts/unpack-zulip @@ -0,0 +1,26 @@ +#!/usr/bin/python -u +import os +import sys +import subprocess +import datetime +import tempfile + +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +from zulip_tools import DEPLOYMENTS_DIR, TIMESTAMP_FORMAT, FAIL, ENDC + +if len(sys.argv) != 2: + print FAIL + "Usage: %s " % (sys.argv[0],) + ENDC + sys.exit(1) + +tarball_path = sys.argv[1] + +timestamp = datetime.datetime.now().strftime(TIMESTAMP_FORMAT) +deploy_path = os.path.join(DEPLOYMENTS_DIR, timestamp) + +extract_path = tempfile.mkdtemp() +subprocess.check_call(["tar", "-xf", tarball_path, "-C", extract_path]) +subprocess.check_call(["mv", os.path.join(extract_path, "zulip-server"), deploy_path]) +subprocess.check_call(["rmdir", extract_path]) + +print deploy_path +sys.exit(0) diff --git a/scripts/upgrade-zulip b/scripts/upgrade-zulip index 0a77112b89..834cd81a26 100755 --- a/scripts/upgrade-zulip +++ b/scripts/upgrade-zulip @@ -6,7 +6,6 @@ import logging import datetime import shutil import time -import tempfile sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from zulip_tools import DEPLOYMENTS_DIR, LOCK_DIR, TIMESTAMP_FORMAT, FAIL, WARNING, ENDC @@ -20,8 +19,6 @@ if len(sys.argv) != 2: tarball_path = sys.argv[1] -subprocess.check_call(["mkdir", '-p', DEPLOYMENTS_DIR, '/home/zulip/logs']) - start_time = time.time() got_lock = False while time.time() - start_time < 300: @@ -46,14 +43,12 @@ timestamp = datetime.datetime.now().strftime(TIMESTAMP_FORMAT) deploy_path = os.path.join(DEPLOYMENTS_DIR, timestamp) logging.info("Unpacking the tarball") -extract_path = tempfile.mkdtemp() -subprocess.check_call(["tar", "-xf", tarball_path, "-C", extract_path]) -subprocess.check_call(["mv", os.path.join(extract_path, "zulip-server"), deploy_path]) -subprocess.check_call(["rmdir", extract_path]) -os.chdir(deploy_path) +deploy_path = subprocess.check_output([os.path.join(os.path.dirname(__file__), 'unpack-zulip'), + tarball_path]) +os.chdir(deploy_path.strip()) logging.info("Restarting server...") -subprocess.check_call(["./scripts/restart-server"]) +subprocess.check_output(["./scripts/restart-server"]) logging.info("Deployment complete") shutil.rmtree(LOCK_DIR)