Is there a way to use capistrano (or similar) to remotely interact with rails console

I'm loving how capistrano has simplified my deployment workflow, but often times a pushed change will run into issues that I need to log into the server to troubleshoot via the console.

Is there a way to use capistrano or another remote administration tool to interact with the rails console on a server from your local terminal?

**Update:

cap shell seems promising, but it hangs when you try to start the console:

cap> cd /path/to/application/current
cap> pwd
 ** [out :: application.com] /path/to/application/current
cap> rails c production
 ** [out :: application.com] Loading production environment (Rails 3.0.0)
 ** [out :: application.com] Switch to inspect mode.

if you know a workaround for this, that'd be great

Answers


I found pretty nice solution based on https://github.com/codesnik/rails-recipes/blob/master/lib/rails-recipes/console.rb

desc "Remote console" 
task :console, :roles => :app do
  env = stage || "production"
  server = find_servers(:roles => [:app]).first
  run_with_tty server, %W( ./script/rails console #{env} )
end

desc "Remote dbconsole" 
task :dbconsole, :roles => :app do
  env = stage || "production"
  server = find_servers(:roles => [:app]).first
  run_with_tty server, %W( ./script/rails dbconsole #{env} )
end

def run_with_tty(server, cmd)
  # looks like total pizdets
  command = []
  command += %W( ssh -t #{gateway} -l #{self[:gateway_user] || self[:user]} ) if     self[:gateway]
  command += %W( ssh -t )
  command += %W( -p #{server.port}) if server.port
  command += %W( -l #{user} #{server.host} )
  command += %W( cd #{current_path} )
  # have to escape this once if running via double ssh
  command += [self[:gateway] ? '\&\&' : '&&']
  command += Array(cmd)
  system *command
end

Need Your Help

Breakpoint set with IntelliJ not working in premain of remote custom java agent

java debugging intellij-idea agent

I've started to implement a simple Java agent that does some instrumentation before a class is loaded by JVM. The thing is I need to do some debugging on this agent, but what I tried so far had fai...

update progress for ASP:Button

javascript jquery asp.net

I want to use show a "Loading Image" on the click of server side button, that should be unloaded after the button event completes.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.