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

Make sure that only one PhantomJS process is running at any single time

parent cc0e6a3d
No related branches found
No related tags found
No related merge requests found
......@@ -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');
......
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