Background jobs with #fork

paddor paddor at
Thu Apr 12 17:36:25 UTC 2012


I've migrated from Passenger to Unicorn about a week ago. It's great.
Great transparency and management, thanks for this great software!

A few of my Rails applications start background jobs using
Kernel#fork. Of course, the ActiveRecord connections are closed and
reopened again in the parent and child processes. The child process
also does its job.

Unfortunately, it seems that the parent (a Unicorn worker) waits for
the child (background job) to finish before serving any new requests.
Process.detach is done in the child. Process.setsid is not done. The
child's STDOUT, STDERR and the Rails logger are redirected to their
own files right after forking.

Software used:
ruby 1.9.1p376
Rubygems 1.8.17
Linux (SUSE 10.2)
unicorn 4.2.1
nginx 0.8.53

The problem persists even when multiple workers are started. And the
problem was not present in the old setup with Passenger.

My question: Does Unicorn somehow check/wait for child processes
forked by the worker processes?

Thanks in advance for your help.


More information about the mongrel-unicorn mailing list