Valentin Mihov <[email protected]> wrote: > On Fri, Oct 3, 2014 at 3:22 PM, Eric Wong <[email protected]> wrote: > > Bráulio Bhavamitra <[email protected]> wrote: > > > Both operations I currently do (server warm up and old pid kill) need > > > to be run only once, and not for every worker as before_fork does, > > > that's why I had to put the condition seen above. > > > > rack.git also has a Rack::Builder#warmup method. Aman originally > > proposed it for unicorn, but it's useful outside of unicorn so > > we moved it to Rack. > > Isn't it much better to do the warmup in an initializer instead in > unicorn? This way you can preload_app=true and the master will execute > the warmup code and fork. Killing the old pid is probably stopping you > from do that, right?
Right, that's exactly what Rack::Builder#warmup does with preload_app=true. If by "initializer" you mean within the application, the problem was it lacked the visibility of the entire Rack middleware stack which Rack::Builder has. ref: http://bogomips.org/unicorn-public/m/571f2d6c6f4b8df644bd84f069fafa5bde3cde2e http://bogomips.org/unicorn-public/m/20130923105807.GA24712%40dcvr.yhbt.net
