It turns out that the thin server is very particular about starting the EventMachine reactor for itself. That would be fine except that there are circumstances where I need to start the reactor because the process is not being run inside of thin.
So the simple question is how can I programatically determine that my Rails application is being started by a thin server? In that case I won't start my own EventMachine reactor, otherwise I have to.
After walking through both Rails and Thin initialization, it appears that there really is no penetration into the
Application
instance fromThin::Server
. That seems to mean that I can't examine my app in order to see the server running it.So I simply opted to check whether
Thin::Server
was defined. Since I have thin loaded with:I'm only going to have the
Thin::Server
class initialized if the application is being started from thin. I've checked the rails console, rake tasks and delayed_jobs workers and the assumption seems to hold.So, in my application.rb: