Created
May 22, 2015 10:33
-
-
Save victrcodes/c7567b03ccdb660cda10 to your computer and use it in GitHub Desktop.
Quick and dirty Play 2.3 deployment to production server script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#Quick and dirty Play 2.3 deployment to production server script using RSYNC and SSH accessed with a key | |
#Requires SSH, RSYNC and SBT to be installed locally | |
#Tested on Ubuntu | |
LOCAL_FOLDER=/home/foo/projects/myapp #Local folder of your Play application root | |
SSH_KEY=/home/foo/.ssh/private_keys/server.pem #Local path to your SSH key | |
REMOTE_FOLDER=/var/web/myapp #Remote folder of your Play application | |
REMOTE_SCRIPT=${REMOTE_FOLDER}/bin/myapp #Remoter path to Play launch script | |
REMOTE_PORT=9666 #Play application's port | |
REMOTE_USER=bar #Remote user | |
REMOTE_HOST=192.168.1.1 #Remote host | |
cd $LOCAL_FOLDER | |
#Compile the application | |
sbt clean stage | |
#Sync (upload) the files with remote server | |
rsync -a --delete ${LOCAL_FOLDER}/target/universal/stage/ -e "ssh -i $SSH_KEY" ${REMOTE_USER}@${REMOTE_HOST}:$REMOTE_FOLDER | |
#Kill the application on remote server and relaunch it | |
ssh -i $SSH_KEY ${REMOTE_USER}@${REMOTE_HOST} "fuser -k ${REMOTE_PORT}/tcp; nohup bash $REMOTE_SCRIPT -Dhttp.port=${REMOTE_PORT} > /dev/null 2>&1 &" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment