2017-12-27 421 views
0

我想访问我的远程服务器的导轨控制台。 Rails的版本:5.1.4 红宝石版本:2.4.3如何使用capistrano访问导轨控制台?

我试图安装宝石https://github.com/ydkn/capistrano-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

回答

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端口是在托管服务器上打开。