I have a middleware for announcing my application on the local network app using Bonjour, but it's also announcing the service when Rails is invoked from rake or through the console.
I'd like to exclude these cases, and only use the Bonjour middleware when Rails is running as a server.
The middleware configuration accepts a proc to exclude middlewares under certain conditions using a proc
:
config.middleware.insert_before ActionDispatch::Static, Rack::SSL, :exclude => proc { |env|
env['HTTPS'] != 'on'
}
But how do I determine if Rails was invoked from the CLI, console or as a server?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…