felixge/node-mysql — Issue #132: ability to set socket connect timeout?
Author: qzaidi
Created: 2011-11-04 17:31:19+00:00
State: open

When my app is started, I would like to start the http server only when the database is connected. node-mysql uses lazy connect, so I have no way of doing this without issuing a db command. Immediately after creating the client, I issue a server ping to force it to connect, as a work-around.

I still have a problem with the client._socket timeout. Sometimes, the DB host may just be unavailable/down, and the socket connect timeout is very large, so it is a couple of minutes before I would know this. Am I doing it wrong - is there another way to make the http serving contingent on a successful mysql connection?