lib/ors/helpers.rb in ors-0.2.4 vs lib/ors/helpers.rb in ors-0.2.5
- old
+ new
@@ -14,62 +14,58 @@
end
def setup_ruby server
info "[#{server}] installing ruby and gems..."
- execute_command server, %(source ~/.rvm/scripts/rvm),
- %(cd #{deploy_directory}),
- %(gem install rubygems-update),
- %(gem update --system),
- %(gem install bundler),
- %(bundle install --without development test osx_development > bundler.log)
+ execute_command server, prepare_environment,
+ %(gem install rubygems-update),
+ %(gem update --system),
+ %(gem install bundler),
+ %(bundle install --without development test osx_development > bundler.log)
end
def update_code server
info "[#{server}] updating codebase..."
- execute_command server, %(cd #{deploy_directory}),
- %(git fetch),
- %(git checkout -q -f origin/#{environment}),
- %(git reset --hard)
+ execute_command server, prepare_environment,
+ %(git fetch),
+ %(git checkout -q -f origin/#{environment}),
+ %(git reset --hard)
end
def bundle_install server
info "[#{server}] installing bundle..."
- execute_command server, %(source ~/.rvm/scripts/rvm),
- %(cd #{deploy_directory}),
+ execute_command server, prepare_environment,
%(bundle install --without development test osx_development > bundler.log)
end
def start_server server
info "[#{server}] starting unicorn..."
- execute_command server, %(source ~/.rvm/scripts/rvm),
- %(cd #{deploy_directory}),
+ execute_command server, prepare_environment,
%(if [ -f config.ru ]; then RAILS_ENV=#{environment} bundle exec unicorn -c config/unicorn.rb -D -E #{environment}; else RAILS_ENV=#{environment} bundle exec unicorn_rails -c config/unicorn.rb -D -E #{environment}; fi)
end
def stop_server server
info "[#{server}] stopping unicorn..."
- execute_command server, %(cd #{deploy_directory}),
+ execute_command server, prepare_environment,
%(kill \\`cat tmp/pids/unicorn.pid\\`)
end
def restart_server server
info "[#{server}] restarting unicorn..."
- execute_command server, %(cd #{deploy_directory}),
+ execute_command server, prepare_environment,
%(kill -USR2 \\`cat tmp/pids/unicorn.pid\\`)
end
def run_migrations server
info "[#{server}] running migrations..."
- execute_command server, %(source ~/.rvm/scripts/rvm),
- %(cd #{deploy_directory}),
+ execute_command server, prepare_environment,
%(RAILS_ENV=#{environment} bundle exec rake db:migrate db:seed)
end
def execute_in_parallel servers
servers.map do |server|
@@ -127,9 +123,14 @@
%(ssh #{quiet_ssh}#{psuedo_tty}#{gateway} 'ssh #{quiet_ssh}#{psuedo_tty}#{deploy_user}@#{server} "#{commands}"')
else
%(ssh #{quiet_ssh}#{psuedo_tty}#{deploy_user}@#{server} "#{commands}")
end
end
+ end
+
+ def prepare_environment
+ [%(source ~/.rvm/scripts/rvm),
+ %({ cd #{deploy_directory} > /dev/null; })] # Silence RVM's "Using... gemset..."
end
def info message
STDOUT.puts message
end