Ruby:并行运行外部进程并跟踪退出代码

Ruby:并行运行外部进程并跟踪退出代码,ruby,ruby-2.0,Ruby,Ruby 2.0,我有一个烟雾测试,我对我的服务器运行之前,使他们生活。目前,它以串行形式运行,每台服务器大约需要60秒。我可以并行运行这些测试,我使用了Thread.new,这很好,因为它运行速度更快,但我无法知道测试是否真正通过 我正试图通过使用Process.spawn来管理我的流程来改进这一点 pids = [] uris.each do |uri| command = get_http_tests_command("Smoke") update_http_tests_config( ur

我有一个烟雾测试,我对我的服务器运行之前,使他们生活。目前,它以串行形式运行,每台服务器大约需要60秒。我可以并行运行这些测试,我使用了
Thread.new
,这很好,因为它运行速度更快,但我无法知道测试是否真正通过

我正试图通过使用
Process.spawn
来管理我的流程来改进这一点

pids = []
uris.each do |uri|
    command = get_http_tests_command("Smoke")
    update_http_tests_config( uri )
    pid = Process.spawn( system( command ) )
    pids.push pid
    Process.detach pid
end

# make sure all pids return a passing status code
# results = Process.waitall
我想启动所有测试,但之后确保所有测试都返回一个通过的状态码

我尝试使用
Process.waitall
,但我认为这是不正确的,用于fork,而不是spawns

在所有过程完成后,如果它们都是pas,我希望返回true状态,如果其中任何一个失败,则返回false状态

试试:

statuses = pids.map { |pid| Process.wait(pid, 0); $? }

这将等待每个进程ID完成,并检查在
$?
中为每个进程设置的结果状态,这就是我喜欢ruby:D的原因