fork on client connection?

Eric Wong normalperson at
Thu Feb 25 17:43:55 EST 2010

Joseph McDonald <superjoe at> wrote:
> Would it be possible to configure unicorn to fork off your rack
> process when it gets a connection from a client as opposed to
> preforking  the workers?  While in development mode I have my app kill
> itself after serving a request, however at that point unicorn fires up
> a new one right away.  If it could wait until it got a connection from
> a client, that would be *super awesome* for development mode.

Hi Joseph,

Instead of forking late, you could avoid building your app until
a client has been accepted.  Try this in your Unicorn config file:

  preload_app false # default
  after_fork do |server, worker| = server.orig_app
    server.preload_app = true
    def server.process_client(client)
      Process.kill(:QUIT, $$) # exit after serving

Eric Wong

More information about the mongrel-unicorn mailing list