Reputation: 1513
I'm ready to deploy a RackServerPages application but can't seem to find a way to disable exceptions i.e, the one rendered by Rack::ShowExceptions.
Thanks!
Upvotes: 6
Views: 1422
Reputation: 4622
As ENV['RACK_ENV']
is the universal Rack solution, Rack-based framework often have higher level solutions.
In the config.rb
it is possible to define :environment
. It is also possible to use ENV['APP_ENV']
.
configure do
set :environment, :production
end
There is an error handling plugin.
class App < Roda
plugin :error_handler do |e|
'Oh No!'
end
end
And also an environment plugin.
class App < Roda
plugin :environments
self.environment = :production
end
Upvotes: 0
Reputation: 41
Set the RACK_ENV
environment variable to deployment
.
Technically, setting ENV['RACK_ENV']
to anything besides development
will disable the exceptions. Rack::ShowExceptions
middleware is included by default when rack is running in the default development
environment.
For Rails apps, set ENV['RACK_ENV']
to deployment
, making sure you also set ENV['RAILS_ENV']
to the correct value for your environment (production
, development
, etc.). If ENV['RAILS_ENV']
is not set, the Rails app will fallback to ENV['RACK_ENV']
and Rails will complain about an unknown deployment
environment.
If you use unicorn
, you can alternatively use -E deployment
to set ENV['RACK_ENV']
to deployment
.
Upvotes: 4
Reputation: 14227
I have several hour unpleasant experience of unsuccessfully trying to disable Rack::ShowExceptions
but in the end I discovered I don't need to do that.
In production this is turned off (when you try to curl -XINVALID -k https://my-production-app.com
it will return just blank screen).
But this won't solve the issue if you need to disable this in custom (e.g. "staging") environment (still showing the rack trace code.)
tested on Rails 3.2.21
on Rails 4.0.12
this works for my production and custom "staging" environment
Upvotes: 1