I need to configure the connection to an external service in my Rails application. I do this in the initializer. The problem is that the service library uses streaming delivery (which I need because I can’t miss it), but the unicorn’s life cycle causes the stream to kill and workers never see it. One solution is to call a new connection for each request, but this is unnecessarily wasteful.
The best solution is to configure the connection in the after_fork block in the unicorn configuration. The problem is that it is not called outside the unicorn, which means that we cannot test it in development / testing environments.
So the question is, what is the best way to determine if a Rails application is running under Unicorn (both the wizard and the workflow)?
source share