From 070c37ccba40b91a68da3bc26ed7d07f076f0039 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Mon, 2 Apr 2012 12:54:14 -0700 Subject: [PATCH] Adding real-time connection counts to logs. --- node/unread_counts.coffee | 4 ++-- node/unread_counts.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/node/unread_counts.coffee b/node/unread_counts.coffee index b9d30af01..d15cd78af 100644 --- a/node/unread_counts.coffee +++ b/node/unread_counts.coffee @@ -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." \ No newline at end of file diff --git a/node/unread_counts.js b/node/unread_counts.js index d9f5da626..ef0f3712b 100644 --- a/node/unread_counts.js +++ b/node/unread_counts.js @@ -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."); }); });