From 1158a86ae7cbe1f7301735548468ea43746d1ad3 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 4 Aug 2016 16:58:57 -0700 Subject: [PATCH] restart-server: Maintain a last symlink. --- scripts/restart-server | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/restart-server b/scripts/restart-server index 938e1bb9d9..b53c79a658 100755 --- a/scripts/restart-server +++ b/scripts/restart-server @@ -31,7 +31,12 @@ logging.info("Stopping workers") subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*"]) logging.info("Stopping server core") subprocess.check_call(["supervisorctl", "stop", "zulip-senders:* zulip-django zulip-tornado"]) -subprocess.check_call(["ln", '-nsf', deploy_path, os.path.join(DEPLOYMENTS_DIR, "current")]) + +current_symlink = os.path.join(DEPLOYMENTS_DIR, "current") +last_symlink = os.path.join(DEPLOYMENTS_DIR, "last") +if os.readlink(current_symlink) != deploy_path: + subprocess.check_call(["ln", '-nsf', os.readlink(current_symlink), last_symlink]) + subprocess.check_call(["ln", '-nsf', deploy_path, current_symlink]) logging.info("Starting server core") subprocess.check_call(["supervisorctl", "start", "zulip-tornado zulip-django zulip-senders:*"]) logging.info("Starting workers")