Ruby 1.8.7是否有类似于"spawn"的功能?

5

在 Ruby 1.8.7 中是否有 spawn 相当的功能?

看起来这个功能是在 1.9.1 版本中引入的。 http://apidock.com/ruby/Kernel/spawn

我需要在 Ruby 1.8.7 中使用以下功能:

def run_worker(queue, count = 1)
  puts "Starting #{count} worker(s) with QUEUE: #{queue}"
  ops = {:pgroup => true, :err => [(Rails.root + "log/resque_err").to_s, "a"], 
                          :out => [(Rails.root + "log/resque_stdout").to_s, "a"]}
  env_vars = {"QUEUE" => queue.to_s}
  count.times {
    ## Using Kernel.spawn and Process.detach because regular system() call would
    ## cause the processes to quit when capistrano finishes
    pid = spawn(env_vars, "rake resque:work", ops)
    Process.detach(pid)
  }
end

如果您认为这是您所引用的问题的重复,那么您没有理解这个问题。您所引用的问题是关于已知/记录功能的一般性问题,该功能是在较新版本的Ruby中引入的。我正在询问如何在较早版本的Ruby中执行相同的操作(即不升级Ruby,因为这对需要生成进程的应用程序不是一个选项)。 - Caleb
1
Process.spawn method, but that seems to be a 1.9+ feature, and I'm limited to Ruby 1.8. - Paul Sweatte
1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接