I have mysql database as engine for django. Django works thought nginx via fastcgi with timeout in 1 min (after that nginx says "504 gateway time-out").
If database gone down, django is trying reconnect to DB and waiting for response from it. And waiting for response too long (more than 1 minute) that nginx returns to client the 504 error code.
How to set timeout for db connecton in django? And what the right way to handle this event and return to client a pretty page with "Sorry database is out of service now. Please try later" instead of technical 504 error page?