Adding real-time connection counts to logs.

This commit is contained in:
Samuel Clay 2012-04-02 12:54:14 -07:00
parent 2bdd2b587d
commit 070c37ccba
2 changed files with 4 additions and 3 deletions

View file

@ -6,7 +6,7 @@ REDIS_SERVER = if process.env.NODE_ENV == 'dev' then 'localhost' else 'db01'
client = redis.createClient 6379, REDIS_SERVER
io.sockets.on 'connection', (socket) ->
console.log " ---> New connection brings total to #{io.sockets.clients().length} consumers."
socket.on 'subscribe:feeds', (feeds, username) ->
socket.subscribe?.end()
socket.subscribe = redis.createClient 6379, REDIS_SERVER
@ -20,5 +20,5 @@ io.sockets.on 'connection', (socket) ->
socket.on 'disconnect', () ->
socket.subscribe?.end()
console.log ' ---> [] Disconnect'
console.log " ---> [] Disconnect, there are now #{io.sockets.clients().length-1} consumers."

View file

@ -12,6 +12,7 @@
client = redis.createClient(6379, REDIS_SERVER);
io.sockets.on('connection', function(socket) {
console.log(" ---> New connection brings total to " + (io.sockets.clients().length) + " consumers.");
socket.on('subscribe:feeds', function(feeds, username) {
var _ref;
if ((_ref = socket.subscribe) != null) _ref.end();
@ -26,7 +27,7 @@
return socket.on('disconnect', function() {
var _ref;
if ((_ref = socket.subscribe) != null) _ref.end();
return console.log(' ---> [] Disconnect');
return console.log(" ---> [] Disconnect, there are now " + (io.sockets.clients().length - 1) + " consumers.");
});
});