[PATCH] preload_app can take an optional block for warmup
normalperson at yhbt.net
Sat Sep 21 08:49:11 UTC 2013
Aman Gupta <aman at tmm1.net> wrote:
Thanks for the patch!
I expect a commit message body to describe why it is useful.
In particular, what benefit does this have over putting the same
code in config.ru or config/initializer.rb (or similar?)
For user-visible config changes like these, it can be similar/identical
to the added documentation.
Anyways, I agree warming up the app is often necessary, but I'm not
convinced it's necessary change unicorn for it. It makes sense
to warmup apps on servers other than unicorn, too.
> --- a/lib/unicorn/http_server.rb
> +++ b/lib/unicorn/http_server.rb
> @@ -721,6 +721,9 @@ class Unicorn::HttpServer
> self.app = app.call
> + if preload_app.respond_to?(:call)
> + preload_app[app]
> + end
Since you're testing for respond_to?(:call), it should be less confusing
to use "preload_app.call(app)" here instead of "preload_app[app]"
More information about the mongrel-unicorn