From: Darren Date: Sun, 27 Jul 2014 16:49:35 +0000 (+0100) Subject: Stats file creating new fd for every write fix X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c25f50e6a488556517e54971419c6f6e90c2b840;p=KiwiIRC.git Stats file creating new fd for every write fix --- diff --git a/server_modules/stats.js b/server_modules/stats.js index b91eb33..8055b36 100644 --- a/server_modules/stats.js +++ b/server_modules/stats.js @@ -11,9 +11,11 @@ var kiwiModules = require('../server/modules'), var module = new kiwiModules.Module('stats_file'); +var stats_file = fs.createWriteStream('kiwi_stats.log', {'flags': 'a'}); + module.on('stat counter', function (event, event_data) { var stat_name = event_data.name, - stats_file, timestamp, + timestamp, ignored_events = []; // Some events may want to be ignored @@ -24,7 +26,5 @@ module.on('stat counter', function (event, event_data) { } timestamp = Math.floor((new Date()).getTime() / 1000); - - stats_file = fs.createWriteStream('kiwi_stats.log', {'flags': 'a'}); stats_file.write(timestamp.toString() + ' ' + stat_name + '\n'); }); \ No newline at end of file