是否有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
答案 0 :(得分:0)
你可以使用这个宝石 - https://github.com/rtomayko/posix-spawn在1.8.7中实现这一点。 它不支持"完整" 1.9的Process :: spawn接口,但是你的例子应该只使用Process :: spawn改为POSIX :: Spawn :: spawn(https://github.com/rtomayko/posix-spawn#status)。