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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    2
  • 1.0.2
    1
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i naemon

Weekly Downloads

5

Version

1.0.3

License

none

Last publish

Collaborators

  • synder