Created
March 7, 2017 19:15
-
-
Save maggiesavovska/d901df4b6d64fa637278281ba501d017 to your computer and use it in GitHub Desktop.
pm2 launchBus() child process sending message after exit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.send({ | |
type : 'process:msg', | |
data : {id:process.pid} | |
}); | |
process.disconnect(); | |
process.exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pm2Config = { | |
"apps": [{ | |
"name": suiteSettings.testName + '_index_' + i, | |
"script": path.normalize('./runners/child.js'), | |
"error_file": reportDir + "err.log", | |
"autorestart": false, | |
maxRestarts: 1, | |
"args": [ | |
'--reportDir=' + suiteSettings.reportDir, | |
'--reportName=' + suiteSettings.suiteName, | |
'--reportTitle=' + suiteSettings.capabilities.browserName, | |
'--capabilities=' + JSON.stringify(suiteSettings.capabilities), | |
'--screenshotDir=' + suiteSettings.screenshotDir, | |
'--loopIndex=' + (count), | |
'--urlData=' + JSON.stringify(suiteSettings.urlData), | |
'--stage=prod', | |
// '--test=' + test, | |
'--color'] | |
}] | |
}; | |
pm2.connect(function (err) { | |
if (err) { | |
console.error(err); | |
process.exit(2); | |
} | |
pm2.start(pm2Config, function (err, proc) { | |
if (err) throw err; | |
pm2.launchBus(function (err, bus) { | |
bus.on('process:msg', function (packet) { | |
console.log(packet.id); //output repeats child id multiple times even after child exits | |
}); // end bus on message | |
return resolve(); | |
});// end launch bus | |
}); // end start | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment