Last active
April 4, 2016 08:55
-
-
Save pirafrank/3af96ca4ddf46b752d46f21e8a5513cf to your computer and use it in GitHub Desktop.
reset/update script to deploy a new stable version of a rails 4.x app served by Puma
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
#!/bin/bash | |
# reset/update script to deploy a new stable version of a rails 4.x app served by Puma. | |
### REQUIREMENTS ### | |
# this script makes use of another script, 'pumascript'.you can find it in my gists. | |
# http://gist.github.com/pirafrank | |
# this script assumes RAILS_ENV is set to 'production' on your server. | |
# put 'export RAILS_ENV=production' in bashrc to do so | |
### NOTES ### | |
# written in a hurry by frank pira. | |
# i'm wrong, never hurry when writing code. | |
# write code responsibly. | |
# feel free to fork this or to let me know about any bugs. | |
### AUTHOR ### | |
# fpira.com <dev[at]fpira[dot]com | |
### LICENSE ### | |
# released under the GNU GPLv3 license. | |
# you can read it here http://www.gnu.org/licenses/gpl-3.0.html | |
### VARIABLES ### | |
DEPLOY_PATH = "." # write here the abs path of your app (e.g. /var/www/rails/awesomeapp) | |
### SCRIPT ### | |
cd "$DEPLOY_PATH" | |
# stopping servers... | |
echo "stopping puma..." | |
pumascript stop | |
echo "stopping delayedjob..." | |
bin/delayed_job stop | |
echo "moving to master branch..." | |
git checkout master | |
echo "resetting to master to remote and discarding any local changes..." | |
git reset --hard origin/master | |
echo "pulling new code..." | |
git pull origin master | |
echo "precompilign assets..." | |
bundle exec rake assets:precompile | |
echo "performing database migration..." | |
rake db:migrate RAILS_ENV=production | |
rake db:seed RAILS_ENV=production | |
# restarting all the things... | |
echo "starting puma..." | |
pumascript start | |
echo "starting delayedjob..." | |
bin/delayed_job start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment