Question

I have this task in may deploy.rb file:

desc 'open ssh session in background'
  task :ssh_in_background do

    run_locally do 
      execute "ssh -o 'ExitOnForwardFailure yes' -NMS ~/.ssh-tunnel -f #{fetch(:rails_env)}-#{fetch(:application)}"
      execute "exit" 
    end
  end

When I run this task, all it does is hang. It never quits despite the -f parameter.

How do I make this task exit so that capistrano will continue on?

Was it helpful?

Solution

I switched from capistrano's execute to ruby's system command.

desc 'open ssh session in background'
  task :ssh_in_background do

    run_locally do 
      system "ssh -o 'ExitOnForwardFailure yes' -NMS ~/.ssh-tunnel -f #{fetch(:rails_env)}-#{fetch(:application)}"
    end
  end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top