Friday, 9 June 2017

How do I use npm forever-monitor to log to stdout

I have a simple nodejs docker service. I'm watching stdout in development and logging to AWS cloudwatch in production.

I've just added forever-monitor, but that breaks my logging. So I've started catching stdout on the child process,

const forever = require('forever-monitor');

const child = new (forever.Monitor)('server.js', {
  max: 3,
  silent: true,
  args: []
});

child.on('stdout', function(data) {
  console.log(data);
});

but that just gives me byte code out -

[nodemon] starting `node forever.js`
<Buffer 63 6f 6e 6e 65 63 74 65 64 20 74 6f 20 6c 69 76 65 20 64 62 0a>

How do I get my console.log statements back into std-out?



via Aidan Ewen

No comments:

Post a Comment