【发布时间】:2015-07-03 02:32:28
【问题描述】:
我正在尝试使用 Capistrano 打开 Rails 控制台,但它关闭了连接 以下脚本我正在使用并打开 rails 控制台
代码
namespace :rails do
desc "Start a rails console, for now just with the primary server"
task :c do
on roles(:app), primary: true do |role|
rails_env = fetch(:rails_env)
execute_remote_command_with_input "#{bundle_cmd_with_rbenv} rails console #{rails_env}"
end
end
def execute_remote_command_with_input(command)
port = fetch(:port) || 22
puts "opening a console on: #{host}...."
cmd = "ssh -l #{fetch(:deploy_user)} #{host} -p #{port} -t 'cd #{deploy_to}/current && #{command}'"
exec cmd
end
def bundle_cmd_with_rbenv
puts "RBENV_VERSION=#{fetch(:rbenv_ruby)} RBENV_ROOT=#{fetch(:rbenv_path)} #{File.join(fetch(:rbenv_path), '/bin/rbenv')} exec bundle exec"
if fetch(:rbenv_ruby)
"RBENV_VERSION=#{fetch(:rbenv_ruby)} RBENV_ROOT=#{fetch(:rbenv_path)} #{File.join(fetch(:rbenv_path), '/bin/rbenv')} exec bundle exec"
else
"ruby "
end
end
end
详情
我使用这个脚本打开 Rails 控制台很多次,但在这几个月里,rails 控制台打开脚本失败了,不知道该怎么办。
输出
RBENV_VERSION=2.1.2 RBENV_ROOT=/home/deployer/.rbenv /home/deployer/.rbenv/bin/rbenv exec bundle exec
opening a console on:
Usage:
rails new APP_PATH [options]
Connection to 45.55.142.39 closed.
任何热门的建议都会起作用
【问题讨论】:
-
谢谢....这对我们有很大帮助
标签: ruby-on-rails ruby capistrano3