Created
November 15, 2017 20:47
-
-
Save olivertappin/7c48520f9796b0f207df32bd7a58e212 to your computer and use it in GitHub Desktop.
Symlink deployments to prevent any downtime whilst files are uploaded and an application is being used
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
BASE="/var/www/project"; RELEASES="$BASE/releases"; RELEASE="$RELEASES/1234567890"; SHARED="$BASE/shared"; CACHE="$BASE/deploy-cache" | |
if [[ `uname` == 'Darwin' ]]; then COPY="cp -a"; else COPY="cp -a"; fi | |
$COPY $CACHE $RELEASE | |
cd $RELEASE | |
####### [Pre-launch commands] ####### | |
composer install -va | |
####### [/Pre-launch commands] ####### | |
if [ $? -ne 0 ]; then echo "Pre-launch commands failed."; exit 1; fi | |
rm -f $RELEASES/current; ln -s $RELEASE $RELEASES/current; mv -f $RELEASES/current $BASE/ | |
cd $RELEASE | |
####### [Post-launch commands] ####### | |
####### [/Post-launch commands] ####### | |
if [ $? -ne 0 ]; then echo "Post-launch commands failed, but the current application symlink was updated."; exit 1; fi | |
echo "Cleaning up old releases" | |
\ls -1d $RELEASES/* | \sort -rg | \tail -n +11 | \xargs /bin/rm -rf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment