diff --git a/plugins/reporting/index.js b/plugins/reporting/index.js index 0298235894bb835ef9433b2cef908a7b5dfe1526..07a6a9316318a16d8d7d6b9ca9b6cfe66dc07c0f 100644 --- a/plugins/reporting/index.js +++ b/plugins/reporting/index.js @@ -23,9 +23,6 @@ exports.initWebApp = function(options) { var count = 0; Ping.on('afterInsert', function(ping) { - if (count > 1) { - return; - } Check.findById(ping.check, function(err, check) { if (err) { return; @@ -45,13 +42,17 @@ exports.initWebApp = function(options) { } } + if (count > 0) { + return; + } + count++; + console.log('PhantomJS started, currently ' + count + ' processes.'); + // Create the report var phantomjs = require('phantomjs-prebuilt'), path = require('path'), program = phantomjs.exec(path.join(__dirname, 'phantomjs-script.js'), config['url'], config['basicAuth']['username'], config['basicAuth']['password'], check._id, output, 'month', date); - count++; - console.log('PhantomJS started, currently ' + count + ' processes.'); program.on('exit', function() { count--; console.log('PhantomJS finished');