Created
March 20, 2015 08:47
-
-
Save jurikern/252dda5a109800393fd3 to your computer and use it in GitHub Desktop.
capistrano_console.rb
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
namespace :rails do | |
desc "Open the rails console on the remote app server" | |
task :console => 'rvm:hook' do | |
on roles(:app), :primary => true do |host| | |
execute_interactively host, "console #{fetch(:stage)}" | |
end | |
end | |
desc "Open the rails dbconsole on each of the remote servers" | |
task :dbconsole => 'rvm:hook' do | |
on roles(:app), :primary => true do |host| | |
execute_interactively host, "dbconsole #{fetch(:stage)}" | |
end | |
end | |
def execute_interactively(host, command) | |
command = "cd #{fetch(:deploy_to)}/current && #{SSHKit.config.command_map[:bundle]} exec rails #{command}" | |
puts command if fetch(:log_level) == :debug | |
exec "ssh -l #{host.user} #{host.hostname} -p #{host.port || 22} -t '#{command}'" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment