Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I turn off exceptions in a Rack app?

Tags:

ruby

rack

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!

like image 782
Sunder Avatar asked Oct 08 '22 02:10

Sunder


1 Answers

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.

like image 194
n00dle Avatar answered Oct 12 '22 00:10

n00dle