From 0de53ac55f1b190e6ce5873780238ccc9f22aa3e Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 23 Oct 2019 18:58:32 -0700 Subject: [PATCH] Update deploy.sh --- tools/deploy.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tools/deploy.sh b/tools/deploy.sh index 0b1a9806..4fa6dfe5 100755 --- a/tools/deploy.sh +++ b/tools/deploy.sh @@ -1,25 +1,29 @@ #!/bin/bash -# Update code and restart server (run from app server) +# Update code and restart server (run on server) set -e -if [ -d "/home/feross/www/instant.io-build" ]; then +if [ -d "/home/feross/www/build-instant.io" ]; then echo "ERROR: Build folder already exists. Is another build in progress?" exit 1 fi -cp -R /home/feross/www/instant.io /home/feross/www/instant.io-build +if [ -d "/home/feross/www/old-instant.io" ]; then + echo "ERROR: Old folder exists. Did a previous build crash?" + exit 1 +fi + +cp -R /home/feross/www/instant.io /home/feross/www/build-instant.io -cd /home/feross/www/instant.io-build && git pull -cd /home/feross/www/instant.io-build && rm -rf node_modules -cd /home/feross/www/instant.io-build && npm install -cd /home/feross/www/instant.io-build && npm run build -cd /home/feross/www/instant.io-build && npm prune --production +cd /home/feross/www/build-instant.io && git pull +cd /home/feross/www/build-instant.io && npm install --no-progress +cd /home/feross/www/build-instant.io && npm run build +cd /home/feross/www/build-instant.io && npm prune --production --no-progress sudo supervisorctl stop instant -cd /home/feross/www && mv instant.io instant.io-old -cd /home/feross/www && mv instant.io-build instant.io +cd /home/feross/www && mv instant.io old-instant.io +cd /home/feross/www && mv build-instant.io instant.io sudo supervisorctl start instant -cd /home/feross/www && rm -rf instant.io-old +cd /home/feross/www && rm -rf old-instant.io