Database Setup
ID #1055
How do I stop my long-running app from periodically disconnecting from MySQL?
MySQL connections timeout after a default of 8 hours, so this is the most likely cause of why MySQL just appears to disappear. There are two immediate solutions:
- Teach your app how to reconnect to the database. If it can detect a connection failure, it can try and reconnect and resume doing its work (though, it is good to distinguish between a more serious error and this periodic problem).
- If your app is a rails app (for instance), set up a cron job to hit one of your lightweight database enabled pages every 7 hours. Doing so will effectively ping the MySQL server, and keep the connection alive.
Tags: -
Related entries:
Last update: 2006-04-04 15:39
Author: Dave Steinberg
Revision: 1.0
You can comment on this entry