-
-
Save ej2015/78a7ad5ef33e34e6712c1eb084bc34d7 to your computer and use it in GitHub Desktop.
Capistrano 3 rails console tasks
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
| # encoding: UTF-8 | |
| # Place in config/deploy.rb | |
| namespace :rails do | |
| desc "Open the rails console on each of the remote servers" | |
| task :console do | |
| on roles(:app) do |host| #does it for each host, bad. | |
| rails_env = fetch(:stage) | |
| execute_interactively "ruby #{current_path}/script/rails console #{rails_env}" | |
| end | |
| end | |
| desc "Open the rails dbconsole on each of the remote servers" | |
| task :dbconsole do | |
| on roles(:db) do |host| #does it for each host, bad. | |
| rails_env = fetch(:stage) | |
| execute_interactively "ruby #{current_path}/script/rails dbconsole #{rails_env}" | |
| end | |
| end | |
| def execute_interactively(command) | |
| user = fetch(:user) | |
| port = fetch(:port) || 22 | |
| exec "ssh -l #{user} #{host} -p #{port} -t 'cd #{deploy_to}/current && #{command}'" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment