2017-12-27 426 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端口是在託管服務器上打開。