【问题标题】:How to access rails console with capistrano?如何使用 capistrano 访问 Rails 控制台?
【发布时间】:2017-12-27 13:16:10
【问题描述】:

我想访问远程服务器的 rails 控制台。 导轨版本:5.1.4 红宝石版本:2.4.3

我已尝试安装 gem https://github.com/ydkn/capistrano-rails-console 我已经按照说明进行操作,但是当我执行“cap production rails:console”时出现错误:

(Backtrace restricted to imported tasks)
cap aborted!
Don't know how to build task 'console' (see --tasks)

(See full trace by running task with --trace)

这里是 Capfile:https://pastebin.com/uNdBuTan / 这里是 deploy.rb 文件:https://pastebin.com/W8ic92Nf

【问题讨论】:

    标签: ruby-on-rails ruby capistrano


    【解决方案1】:

    通过在 deploy.rb 中添加以下行解决了同样的问题

    namespace :rails do
     desc "Open the rails console on one remote server"
     task :console, :roles => :app do
       hostname = find_servers_for_task(current_task).first
       port = exists?(:port) ? fetch(:port) : 22
       exec "ssh -l #{user} #{hostname} -p #{port} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'"
     end
    end
    

    确保 ssh 端口 在托管服务器上打开。

    【讨论】:

      【解决方案2】:

      检查这个宝石:

      【讨论】:

      • 是的,我有 capistrano-rails-console,但它不起作用
      猜你喜欢
      • 1970-01-01
      • 2016-09-10
      • 1970-01-01
      • 1970-01-01
      • 2019-07-29
      • 2022-08-15
      • 1970-01-01
      • 2012-03-23
      • 1970-01-01
      相关资源
      最近更新 更多