Skip to content
Snippets Groups Projects
Commit d749187e authored by jurgenhaas's avatar jurgenhaas
Browse files

Make sure that no more than 3 PhantomJS processes are running at once

parent 547c66db
No related branches found
No related tags found
No related merge requests found
......@@ -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');
});
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment