Skip to content

Instantly share code, notes, and snippets.

@pirafrank
Last active April 4, 2016 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirafrank/3af96ca4ddf46b752d46f21e8a5513cf to your computer and use it in GitHub Desktop.
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
#!/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