加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何通过capistrano进入rails控制台?

发布时间:2020-12-16 20:29:01 所属栏目:百科 来源:网络整理
导读:我想通过capistrano从本地计算机进入生产服务器上的rails控制台. 我发现了一些要点,例如 https://gist.github.com/813291当我进入控制台 cap production console 我得到以下结果 192-168-0-100:foldername username $cap console RAILS_ENV=production * exe
我想通过capistrano从本地计算机进入生产服务器上的rails控制台.
我发现了一些要点,例如 https://gist.github.com/813291当我进入控制台
cap production console

我得到以下结果

192-168-0-100:foldername username $cap console RAILS_ENV=production
  * executing `console'
  * executing "cd /var/www/myapp/current && rails console production"
    servers: ["www.example.de"]
    [www.example.de] executing command
    [www.example.de] rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3' -c 'cd /var/www/myapp/current && rails console production'
/var/www/myapp/releases/20120305102218/app/controllers/users_controller.rb:3: warning: already initialized constant VERIFY_PEER
Loading production environment (Rails 3.2.1)
Switch to inspect mode.

这就是…现在我可以输入一些文字,但什么也没有发生…

有人有一个想法如何获得这个工作或另一个解决方案为我的问题?

解决方法

我为这种事情添加了自己的任务:
namespace :rails do
  desc "Remote console"
  task :console,:roles => :app do
    run_interactively "bundle exec rails console #{rails_env}"
  end

  desc "Remote dbconsole"
  task :dbconsole,:roles => :app do
    run_interactively "bundle exec rails dbconsole #{rails_env}"
  end
end

def run_interactively(command)
  server ||= find_servers_for_task(current_task).first
  exec %Q(ssh #{user}@#{myproductionhost} -t '#{command}')
end

我现在说cap rails:控制台,并得到一个控制台.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读