Sending command to child process?

133 Views Asked by At

I'm quite new working with Forever-monitor, but I am wondering if it is possible to send a command to a child process?

As I would like to terminate the need for it to check a database, which is my current solution for the issue.

I am starting the bots with specific ids, so the childs starting would be named bot1, bot2 etc.

So lets say I would like to send a command to bot1, and see the data it returns, would this be possible?

Just a link in the right direction would be perfect if possible.

Here's the code used for starting the child.

console.log('Launching bot# '+itm.id);
botid = 'bot'+itm.id;
var botid = new (forever.Monitor)('bot.js', {
  uid: 'bot'+itm.id,
  args: [itm.id]
});
botid.on('start', function(process, data) {
  console.log('Bot with ID '+itm.id+' started');
});
botid.on('exit:code', function(code) {
  console.log('Bot stopped with code '+code);
});
botid.on('stdout', function(data) {
  console.log(data);
});
botid.start();

0

There are 0 best solutions below