Is there a spawn equivalent for ruby 1.8.7?
It appears as though it was introduced in 1.9.1 http://apidock.com/ruby/Kernel/spawn
I need the following to work in 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
You can achieve this in 1.8.7 using this gem - https://github.com/rtomayko/posix-spawn. It does not support "full" 1.9's Process::spawn interface, but your example should work with it just by changing Process::spawn to POSIX::Spawn::spawn (https://github.com/rtomayko/posix-spawn#status).