Created
November 17, 2013 22:35
-
-
Save gonfva/7519177 to your computer and use it in GitHub Desktop.
Script to update a running server (rvm+puma+nginx)
This file contains hidden or 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 | |
| pwd=***** | |
| if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then | |
| # First try to load from a user install | |
| source "$HOME/.rvm/scripts/rvm" | |
| elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then | |
| # Then try to load from a root install | |
| source "/usr/local/rvm/scripts/rvm" | |
| else | |
| printf "ERROR: An RVM installation was not found.\n" | |
| exit 1 | |
| fi | |
| rvm use default | |
| cd /home/gonfva/whendoigo2 | |
| #Import new code | |
| git pull origin | |
| #Install new libraries | |
| RAILS_ENV=production bundle install | |
| #Precompile assets | |
| RAILS_ENV=production bundle exec rake assets:precompile | |
| #Migrate database | |
| RAILS_ENV=production bundle exec rake db:migrate | |
| #Kill current processess | |
| pid=`ps -L n | grep "puma" |awk '{ print $1 }'` | |
| if [[ $pid != "" ]]; | |
| then | |
| kill -s SIGTERM $pid | |
| fi | |
| echo $pwd| sudo -S service nginx stop | |
| #Remove communication file | |
| rm -f /tmp/whendoigo.sock | |
| #start Puma | |
| bundle exec puma -e production -b unix:///tmp/whendoigo.sock & | |
| sleep 10 | |
| #start nginx | |
| echo $pwd| sudo -S service nginx start |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Next time capistrano at least.