我很喜欢capistrano如何简化了我的部署工作流程,但是经常会有一次推送的更改会遇到我需要登录服务器以通过控制台进行故障排除的问题.
有没有办法使用capistrano或其他远程管理工具与本地终端上的服务器上的rails控制台进行交互?
**更新:
帽壳看起来很有希望,但是当您尝试启动控制台时它会挂起:
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.
如果你知道一个解决办法,那将是巨大的
解决方法
我发现基于
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,%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