Joseph McDonald <superjoe at gmail.com> 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.app = server.orig_app
server.preload_app = true
def server.process_client(client)
build_app!
Process.kill(:QUIT, $$) # exit after serving
super
end
end
--
Eric Wong