Created
September 18, 2012 03:44
-
-
Save nukturnal/3741120 to your computer and use it in GitHub Desktop.
Simple script to help with Rails deployment tasks. Requires "Rye Gem"
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
require 'rubygems' | |
require 'rye' | |
HOST = "yourserver" | |
USER = "username" | |
PASS = "password" | |
app_path = "/path/to/rails_app_root" | |
production_env = "RAILS_ENV=production" | |
# You can tailor the various commands you run on your below | |
# If you have rails instailed via rvm this script might fail | |
# rvm by default is set to work under interactive shell mode. | |
# To load rvm under non-interactive mode edit your $HOME/.bashrc | |
# and place source the script below above this line [ -z "$PS1" ] && return | |
# 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" | |
# | |
# fi | |
Rye::Cmd.add_command :bundle, 'bundle' | |
Rye::Cmd.add_command :restart_app, "touch tmp/restart.txt" | |
Rye::Cmd.add_command :git_pull, "git pull" | |
Rye::Cmd.add_command :restart_app, "touch #{app_path}" | |
Rye::Cmd.add_command :rake_migrate, "rake db:migrate #{production_env}" | |
Rye::Cmd.add_command :assets_precompile, "bundle exec rake assets:precompile" | |
puts "Logginging into server" | |
rbox = Rye::Box.new(HOST, :user => USER, :password => PASS) | |
puts "Logged in" | |
puts "Going into #{app_path}" | |
rbox.cd app_path | |
puts rbox.pwd | |
puts "Pulling latest git repos" | |
puts rbox.git_pull | |
puts "Running the bundle command" | |
puts rbox.bundle | |
puts "Running migrations" | |
puts rbox.rake_migrate | |
puts "Assets pipeline precompilation" | |
puts rbox.assets_precompile | |
puts "Rebooting app..." | |
rbox.restart_app | |
puts "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment