Commit dd1918dc authored by indexzero's avatar indexzero

[debug] Better debug messages to try to determine if pool is slowly losing clients to forever busy

parent 7c2eb5de
......@@ -30,7 +30,7 @@ var sys = require('sys'),
pool = require('./../vendor/pool/main'),
eyes = require('eyes'),
min = 0,
max = 100;
max = 10;
// Setup the PoolManager
var manager = pool.createPoolManager();
......@@ -146,7 +146,7 @@ HttpProxy.prototype = {
// Open new HTTP request to internal resource with will act as a reverse proxy pass
var p = manager.getPool(port, server);
sys.puts('current pool count for ' + req.headers.host + ":" + port + ' ' +p.clients.length);
sys.puts('Current pool count for ' + req.headers.host + ":" + port + ' ' + p.clients.length + ', Busy: ' + p.getBusy() + ', Free: ' + p.getFree());
p.on('error', function (err) {
// Remark: We should probably do something here
......
......@@ -84,6 +84,14 @@ Pool.prototype.onFree = function (client) {
if (this.pending.length > 0) this.pending.shift()(client);
};
Pool.prototype.getFree = function () {
return this.clients.filter(function (client) { return !client.busy }).length;
};
Pool.prototype.getBusy = function () {
return this.clients.filter(function (client) { return client.busy }).length;
};
Pool.prototype.setMinClients = function (num) {
this.minClients = num;
if (this.clients.length < num) {
......@@ -98,6 +106,7 @@ Pool.prototype.setMinClients = function (num) {
Pool.prototype.setMaxClients = function (num) {
this.maxClients = num;
};
Pool.prototype.end = function () {
this.clients.forEach(function (c) {c.end()});
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment