some varnish sanity checks

This commit is contained in:
javi
2011-12-05 15:50:47 +01:00
parent b86d3ae35e
commit db55c08be1
+14
View File
@@ -8,6 +8,7 @@ var net = require('net')
function VarnishClient(host, port, ready_callback) {
var self = this;
var ready = false;
var cmd_callback = null;
var client = null;
@@ -39,6 +40,14 @@ function VarnishClient(host, port, ready_callback) {
});
client.on('error', function(err) {
console.log("[ERROR] some problem in varnish connection");
});
client.on('close', function() {
self.close();
});
// sends the command to the server
function _send(cmd, callback) {
cmd_callback = callback;
@@ -98,6 +107,7 @@ function VarnishPool(opts, ready) {
function VarnishQueue(host, port) {
var MAX_QUEUE = 2000;
var queue = [];
var ready = false;
@@ -122,6 +132,10 @@ function VarnishQueue(host, port) {
this.run_cmd = function(cmd) {
queue.push(cmd);
if(queue.length > MAX_QUEUE) {
console.log("varnish commando queu too long, removing commands");
queue.pop();
}
if(ready) {
_send_pending();
}