reconnect if varnish is down

This commit is contained in:
Simon Tokumine 2011-12-06 16:32:23 +00:00
parent 37cf676063
commit 74cd176eb5
2 changed files with 12 additions and 3 deletions

View File

@ -9,8 +9,9 @@ var CartodbWindshaft = function(serverOptions) {
// set the cache chanel info to invalidate the cache on the frontend server
serverOptions.afterTileRender = function(req, res, tile, headers, callback) {
res.header('X-Cache-Channel', req.params.dbname);
res.header('Last-Modified','Wed, 30 Aug 1978 00:00:00 GMT'); // special date in the past.
res.header('Cache-Control','no-cache,must-revalidate, public');
// note - not invalidating properly
// res.header('Last-Modified','Wed, 30 Aug 1978 00:00:00 GMT'); // special date in the past.
// res.header('Cache-Control','no-cache,must-revalidate, public');
callback(null, tile, headers);
};

View File

@ -51,7 +51,15 @@ function VarnishClient(host, port, ready_callback) {
// sends the command to the server
function _send(cmd, callback) {
cmd_callback = callback;
client.write(cmd + '\n');
// If varnish down attempt simple reconnect
try{
client.write(cmd + '\n');
} catch(err) {
self.close();
connect();
client.write(cmd + '\n');
}
}
// run command if there is no peding response