Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AlekseyKorzun/7bef94033c5f5cf3a57e4a900efe3ddc to your computer and use it in GitHub Desktop.
Save AlekseyKorzun/7bef94033c5f5cf3a57e4a900efe3ddc to your computer and use it in GitHub Desktop.
Jenkins deploy configuration for NAMP environments
# Extract payload
mkdir -p /www/site/packages/${BUILD_ID}/
tar -zxf /www/site/packages/package.tar.gz -C /www/site/packages/${BUILD_ID}/
# Maintenance logic
IS_MAINTENANCE=true
if [ ! -f "/www/site/packages/${BUILD_ID}/www/maintenance.flag" ]; then
IS_MAINTENANCE=false
touch "/www/site/packages/${BUILD_ID}/www/maintenance.flag"
fi
# Load configuration
cp -r /www/site/packages/${BUILD_ID}/packages/site/configs/production/app /www/site/packages/${BUILD_ID}/package/site/source/
# Reload assets toggle for CDN
if [ ${RELOAD_ASSETS} != true ]; then
touch /www/site/packages/${BUILD_ID}/package/site/source/media/js/*
touch /www/site/packages/${BUILD_ID}/package/site/source/media/css/*
fi
# Maintenance mode for current version
touch /www/site/packages/${BUILD_ID}/www/maintenance.flag
# Stop services
sudo service php-fpm stop
# Switch to new version
ln -n -f -s /www/site/packages/${BUILD_ID}/packages/site/ /www/sites/current
# Start services
sudo service newrelic-daemon restart
sudo service php-fpm start
sudo service nginx reload
# If maintenance mode was previously set, leave it as is
if [ "${IS_MAINTENANCE}" == false ]; then
rm -f /www/site/packages/${BUILD_ID}/www/maintenance.flag
fi
# Request resources to trigger re-cache / APC
wget -q http://__WEB_X__.__DOMAIN__.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment