-
-
Save codemilan/1f9ed4cc1f8acd550c668c95f834a555 to your computer and use it in GitHub Desktop.
Open a Rails console via Capistrano 3 (requires capistrano-rvm 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 'capistrano/rvm' |
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
group :development do | |
# Use Capistrano for deployment | |
gem 'capistrano', '~> 3.3' | |
gem 'capistrano-rvm', '~> 0.1.2', require: false | |
end |
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