Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 有没有办法使用capistrano(或类似的)远程与rails控制台进行交互大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我很喜欢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 @R_509_10586@l 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

大佬总结

以上是大佬教程为你收集整理的ruby-on-rails – 有没有办法使用capistrano(或类似的)远程与rails控制台进行交互全部内容,希望文章能够帮你解决ruby-on-rails – 有没有办法使用capistrano(或类似的)远程与rails控制台进行交互所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。