For most of my sites, and for iBegin especially, we rely heavily on our database. Today we went through a distro upgrade for the database server, and it occurred to me, that we had no good solution for handling these kinds of situations (auto-magically even). I quickly through up a middleware which takes (MySQL only) database OperationalError’s and verifies if it’s an “Unable to connect error”.
Since we have other solutions for monitoring our database, we can safely assume that anytime the database throws this error it roughly translates to “we know the database is down, pretend we did it on purpose”. When it happens, we just throw up a simple template telling the user we’re doing some maintenance and we’ll be back shortly.
So, here’s the random code blurb of the [insert interval]:
1 2 3 4 5 6 7 8 9 10 | |