diff --git a/plugins/reporting/index.js b/plugins/reporting/index.js index d5a5c978a48d1440b02e6f83aca195bc18249658..b4039d86cae4b09033a6b85795e4eb89b5f509e7 100644 --- a/plugins/reporting/index.js +++ b/plugins/reporting/index.js @@ -19,11 +19,13 @@ var Ping = require('../../models/ping'); exports.initWebApp = function(options) { - var api = options.api; var config = options.config; - var dashboard = options.dashboard; + var count = 0; Ping.on('afterInsert', function(ping) { + if (count > 3) { + return; + } Check.findById(ping.check, function(err, check) { if (err) { return; @@ -36,6 +38,13 @@ exports.initWebApp = function(options) { 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, check.name, 'month', Date.now()); + + count++; + console.log('PhantomJS started, currently ' + count + ' processes.'); + program.on('exit', function() { + count--; + console.log('PhantomJS finished'); + }); }); });