Sunday 21 May 2017

pass arguments to target script in forever-monitor npm script

I am using forever-monitor nom module to run sample.js script forever. I am trying to send arguments from index.js(where I am using below code to initialize forever-monitor module) to target script i.e. sample.js. There is an option for this i.e. args however, when I am trying to send arguments with this option and access that argument in sample.js file it returns undefined. How can I pass argument and access it in target script using forever-monitor?

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

let child = new (forever.Monitor)(‘sample.js', {
    'silent': false,
    'args': ['foo']
});

child.on('exit', () => {
    console.log(‘sample.js has exited.’);
});

child.start();



via 2619

No comments:

Post a Comment