\#3134 double callback fix

This commit is contained in:
Unitech 2017-09-14 18:21:04 +02:00
parent f1c24d485f
commit 374f88ba0a
2 changed files with 10 additions and 3 deletions

View File

@ -2,6 +2,7 @@
- #3150 fix watchdog on agent
- #3001 dump-backup feature
- #3134 edge case error handling
- #3096 fix module installation
- #3085 honor every pm2 args on restart
- #3046 better error message if PM2 is misconfigured

View File

@ -154,14 +154,20 @@ var Utility = module.exports = {
flows.push(function(next){
var file = stds[io];
// if file contains ERR or /dev/null, dont try to create stream since he dont want logs
if (!file || file.indexOf('NULL') > -1 || file.indexOf('/dev/null') > -1)
return next();
stds[io] = fs.createWriteStream(file, {flags: 'a'})
.once('error', function(err){
next(err);
})
.once('error', next)
.on('open', function(){
stds[io].removeListener('error', next);
stds[io].on('error', function(err) {
console.error(err);
});
next();
});
stds[io]._file = file;