Skip to content

Instantly share code, notes, and snippets.

@stas
Created December 13, 2013 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stas/7946457 to your computer and use it in GitHub Desktop.
Save stas/7946457 to your computer and use it in GitHub Desktop.
Capistrano 3 console (Rails/SSH) tasks
namespace :rails do
desc 'Opens the Rails console'
task :console => ['deploy:set_rails_env'] do
on primary fetch(:migration_role) do
within release_path do
with rails_env: fetch(:rails_env) do
cmd_string = command(:rails, 'console').to_command
exec 'ssh %s -l %s -p %s -t "%s"' % [
host.hostname, host.username, host.port, cmd_string]
end
end
end
end
end
namespace :deploy do
desc 'Opens an interactive remote shell'
task :console do
on roles(:all) do
exec 'ssh %s -l %s -p %s' % [
host.hostname, host.username, host.port]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment