naemon

1.0.3 • Public • Published

sample code

var path = require('path');
var Naemon = require('naemon');
var daemon = new Naemon();

var scriptPath = path.join(__dirname, './lib/agent.js'); //child script path
var args = [1,2,3]; //args will be send to child process

daemon.start(scriptPath, args); //start Child with damon

//when child process send message , this function will be callback
daemon.receive(scriptPath, function(message){
    console.log(message);
});

//receive all child process message 
daemon.receive(function(message){
    console.log(message);
});

//send message to child process which's path == scriptPath 
daemon.message(scriptPath, { time : Date.now() });

//send message to all child process which is daemoned by this daemon
daemon.message({ time : Date.now() });

//stop
daemon.stop(scriptPath);
//daemon.stop(); //this will stop all child process start by this daemon

Dependents (0)

Package Sidebar

Install

npm i naemon

Weekly Downloads

3

Version

1.0.3

License

none

Last publish

Collaborators

  • synder