Skip to content

Instantly share code, notes, and snippets.

@timemachine3030
Last active August 29, 2015 14:05
Show Gist options
  • Save timemachine3030/175b44887bf5ff2ea36c to your computer and use it in GitHub Desktop.
Save timemachine3030/175b44887bf5ff2ea36c to your computer and use it in GitHub Desktop.
Update a rackspace nodejs delopyment
#!/bin/bash -e
cd /var/apps
GIT=`which git`
REPO=$1
echo repo: $REPO
## Get the hash othe origin/master
HASH=$(eval GIT_SSH=/var/apps/deploy-ssh-wrapper $GIT ls-remote $REPO refs/heads/master | awk '{print $1}')
## Clone origin master
if [ ! -d "releases/$HASH" ]; then
echo cloning: releases/$HASH
GIT_SSH=/var/apps/deploy-ssh-wrapper $GIT clone $REPO --depth=1 releases/$HASH
## Reset symlink
rm current
ln -s releases/$HASH current
## update
cd current
npm install
cd -
else
echo clone exists: releases/$HASH
fi
source env.bash
## restart server (stop/restart to get new environment)
forever stop current/server.js
forever start current/server.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment