运行退出的本地ssh任务
我在may deploy.rb文件中有此任务:运行退出的本地ssh任务,ssh,capistrano,local,capistrano3,Ssh,Capistrano,Local,Capistrano3,我在may deploy.rb文件中有此任务: 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"
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
当我运行此任务时,它所做的只是挂起。尽管有-f
参数,它从不退出
如何使此任务退出,以便capistrano继续运行?我从capistrano的
执行
切换到ruby的系统
命令
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
你找到解决办法了吗?我正在尝试类似的方法,通过SSH隧道运行rails控制台。我的代码看起来像:
task:console=>[:“deploy:set_rails_env”]do host=roles(:app)。首先在本地运行并执行“ssh{host.user}@{host}-i{host.netssh_选项[:key]。第一个}-t'cd}{current_path}&&bundle exec rails}{task}{fetchend end
但它在大约40秒后保持超时,并输出“由于stdin不是终端,因此不会分配伪终端”。这曾经适用于cap 2.15.4,但我最近升级到cap3@IsaacBetesh我从capistrano的execute
切换到ruby的system
命令。谢谢。这对我不起作用;我还必须在本地删除run\u
。请参阅下面我对您答案的评论。我无法让它像这样工作。也许我的情况有所不同,因为我使用的是ssh-t
,而您使用的是ssh-f
。在任何情况下,我的解决方案都只是在本地删除run\u
。我的任务现在看起来是这样的:task:console=>[:“deploy:set_rails_env”]do host=roles(:app).first-system“ssh{host.user}}{host}-i{host.netssh_选项[:key]。first}-t'cd{current#path}&&bundle exec rails console}{fetch fetch(:rails_env)}'end