Rails: Display Maintenance Page if No Database Connection Available
- by RobB
I'm looking for a solution that will allow my rails app to render a user-friendly maintenance page when there is no Mysql server available to connect to.
Normally a Mysql::Error is thrown from the mysql connection adapter in active_record. Something like:
/!\ FAILSAFE /!\ Wed May 26 11:40:14 -0700 2010
Status: 500 Internal Server Error
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
Is there a low-overhead way to catch this error and render a maintenance page instead?
I'm assuming that since connections are actually made in the active_record mysql adapter the app never makes it to the controller stack before it throws the error, so you can't catch it in a controller.
Any input would be greatly appreciated.