I am trying to open rails console using Capistrano but its close the connection Following script i am using and open rails console
Code
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
Details
I am using this script to open rails console so many time ant its work but for the couple of month rails console opening script is fail and don't know what to do with this.
Output
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.
Any Suggestion hot it will work