Ruby 继续Mixlib::ShellOut::CommandTimeout

Ruby 继续Mixlib::ShellOut::CommandTimeout,ruby,chef-infra,Ruby,Chef Infra,如何从Mixlib::ShellOut::CommandTimeout捕获/解救 基本上,我运行的是一个命令,它打开一个进程,永远不会返回,我只想关闭打开的进程,继续我的厨师食谱,因为不返回并不重要 以下是我尝试的代码: begin execute 'install_visual_studio_settings' do command "\"#{node.run_state['installed_path']}\\devenv.exe\" /ResetSettings

如何从Mixlib::ShellOut::CommandTimeout捕获/解救

基本上,我运行的是一个命令,它打开一个进程,永远不会返回,我只想关闭打开的进程,继续我的厨师食谱,因为不返回并不重要


以下是我尝试的代码:

begin
    execute 'install_visual_studio_settings' do
        command "\"#{node.run_state['installed_path']}\\devenv.exe\" /ResetSettings #{node.run_state['tmp_dir']}\\XXXX.vssettings"
        timeout 80
    end
rescue Mixlib::ShellOut::CommandTimeout
    execute 'kill visual studio' do
        command "taskkill /IM \"devenv.exe\" /F"
    end
end

如果第一个
execute
命令的结果并不重要,您可以降低超时时间并使用公共属性

也许还有一种方法可以使用windows的START/B命令而不必等待超时