I want to use forever-monitor package to send me an email when my server crashes.
By going to the homepage I can see that an error is created and my server is restarted after the error. But I want to be able to capture these events (restart and error) so that I can log and send warning emails. But my debugger doesn't stop on error and restart events. Also, those console messages aren't printed.
I run it from command line as node myfilename.js, app.js is my main file.
Thanks for the help !
var forever = require('forever-monitor');
var child = new (forever.Monitor)('app.js', {
max: 3,
silent: false,
args: [],
});
child.on('error', function (err) {
console.log('An error occured '+err);
});
child.on('restart', function() {
console.log('Restarting file');
});
child.start();
setTimeout(function () {
throw new Error('I created an error');
}, 200);