如何使用capistrano访问rails控制台?

问题描述 投票:0回答:2

我想访问我的远程服务器的rails控制台。 Rails版本:5.1.4 Ruby版本: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
2个回答
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端口。


0
投票

检查这个宝石:

© www.soinside.com 2019 - 2024. All rights reserved.