Fix bad handling of child proc stderr

This commit is contained in:
Annika Backstrom 2017-04-09 14:08:22 -04:00
parent 1f533d25fb
commit 7c50a17671
4 changed files with 7 additions and 5 deletions

View File

@ -18,11 +18,11 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit
this.childProcess = spawn(cmd, args); this.childProcess = spawn(cmd, args);
this.childProcess.on('error', function(err) { this.childProcess.on('error', function(err) {
logger.error("process error", { name: name, err: err }); this.logger.error("process error", { class: this.constructor.name, name: name, err: String(err).trim() });
}); });
this.childProcess.on('close', function(code, signal) { this.childProcess.on('close', function(code, signal) {
logger.debug("process closed", { name: name, code: code, signal: signal }); this.logger.debug("process closed", { class: this.constructor.name, name: name, code: code, signal: signal });
}); });
this.childProcess.stdout.on('data', (data) => { this.childProcess.stdout.on('data', (data) => {
@ -33,7 +33,7 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit
}); });
this.childProcess.stderr.on('data', (data) => { this.childProcess.stderr.on('data', (data) => {
this.emit('message', lines[i]); this.logger.error('process stderr', { class: this.constructor.name, stderr: String(data).trim()});
}); });
} }

View File

@ -4,7 +4,7 @@ const ChildProcessEmitter = require('./child-process').ChildProcessEmitter;
class MediaPlayer extends ChildProcessEmitter { class MediaPlayer extends ChildProcessEmitter {
constructor(config, logger) { constructor(config, logger) {
super(config.mpg321); super(config.mpg321, logger);
} }
} }

View File

@ -4,7 +4,7 @@ const ChildProcessEmitter = require('./child-process').ChildProcessEmitter;
class TagReader extends ChildProcessEmitter { class TagReader extends ChildProcessEmitter {
constructor(config, logger) { constructor(config, logger) {
super(config.tag_reader); super(config.tag_reader, logger);
} }
} }

View File

@ -66,6 +66,8 @@ function lookup(tag, cb) {
return cb('PAUSE', 2); return cb('PAUSE', 2);
} }
return cb('PLAY foo');
glob('media/' + tag + ' - *.mp3', function(er, files) { glob('media/' + tag + ' - *.mp3', function(er, files) {
if (files.length > 0) { if (files.length > 0) {
appendLog(files[0]); appendLog(files[0]);