{"_id":"intercom","_rev":"32-f7eff1b4e756ec70f08389dc112e2973","name":"intercom","description":"Create child processes with dnode-protocol based event communication over the nodejs IPC channel, with monitor and control functions for the lifecycle of the created child process.","dist-tags":{"latest":"0.5.1"},"versions":{"0.1.1":{"name":"intercom","version":"0.1.1","description":"dnode-protocol based event intercom using child_process.fork() function including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"git://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.10","eventemitter2":"0.4.x","node-fork":"0.0.x"},"engines":{"node":"0.4.x"},"_npmJsonOpts":{"file":"/home/sander/.npm/intercom/0.1.1/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"intercom@0.1.1","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.27","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"e95db37db2370d60b7c5bc7ac2959a1edce44be8","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.1.1.tgz","integrity":"sha512-L3KQmCNafdqPfCv/QQuUqXiZwIvkvTN0yn0u7n1UvL6wXy+yThODO/cz71ldznls3MXuv9gkqg/gPD+do/eJMA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICc2Cr4IZLPsyv6jWyXGmPP2JkJCFRMjRnRHM/R9/5ykAiEAlL0COhZ0zzTQxdFw2KLSnm5JHJRsx+pXq/YgpV70pYc="}]},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.1.2":{"name":"intercom","version":"0.1.2","description":"dnode-protocol based event intercom using child_process.fork() function including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"git://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.10","eventemitter2":"0.4.x","node-fork":"0.0.x"},"engines":{"node":"0.4.x"},"_npmJsonOpts":{"file":"/home/sander/.npm/intercom/0.1.2/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"intercom@0.1.2","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.27","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"5b1815ccf87fc549308a0f9702f97e348937399f","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.1.2.tgz","integrity":"sha512-5/KxpW9JhnjDctz1Q8ZnWb53RVu5CgV+UQhi9xn8MFPXsrhb8BhCQ/x26R6V5W//U+MNhw1GvOi8Wf3N5Taoqw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDTL7kzTyWgo245H+3qRFkxNvB3UbjPMFbtvnk0Wjr1fAiEA6KHbeTKZwxsxYcnQVT8wJ+oh/erb2EijUYo95JkepO4="}]},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.1.3":{"name":"intercom","version":"0.1.3","description":"dnode-protocol based event intercom using child_process.fork() function including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"git://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.12","eventemitter2":"0.4.x","node-fork":"0.1.x"},"engines":{"node":"0.4.x"},"_npmJsonOpts":{"file":"/home/sander/.npm/intercom/0.1.3/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"intercom@0.1.3","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.27","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"491d3c31253cc1ea14ba60cb152d6cad9cf5ba2f","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.1.3.tgz","integrity":"sha512-0f+y0TFF48L1W6pfaBpqKmKWO/3X69sZGsN8B9RrVIyLwlFDCgPCvo292IJAcBd6UMeouiau2zPTSWEagl7GfQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDExOajgwtMzjYCOGufipz8rhWodEAqDOn7WZK3+eMPTAiEA49QaQ/M1WFESMeRr6hHdWjALzIyZLM9E5HhvCIc+y6c="}]},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.2.0":{"name":"intercom","version":"0.2.0","description":"dnode-protocol and EventEmitter2 based event intercom using child_process.fork() function. Including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"git://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.12","eventemitter2":"0.4.x","node-fork":"0.1.x"},"engines":{"node":"0.4.x"},"_npmJsonOpts":{"file":"/home/sander/.npm/intercom/0.2.0/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"intercom@0.2.0","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.27","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"37c010f8ca8f9d165f436b773be718d6b7c638e9","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.2.0.tgz","integrity":"sha512-+dyBheu695iujzcbEXQJNhc7QO7T0X/VjgnmGnvv9fZHhRLX0Jt1X4Zm9lUIjgi1CaBMxarMVKuoy9ZiFwxX4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBzrPGYlZsrPmLtMGrrXZLUoMJvAII8te1SgWJfuK0M1AiEAgpGmxemdLYlUnlugEZhUQ1m3lc0zcJh0erX70LUgaXo="}]},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.2.1":{"name":"intercom","version":"0.2.1","description":"dnode-protocol and EventEmitter2 based event intercom using child_process.fork() function. Including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"git://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.12","eventemitter2":"0.4.x","node-fork":"0.1.x"},"engines":{"node":"0.4.x"},"_npmJsonOpts":{"file":"/home/sander/.npm/intercom/0.2.1/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"intercom@0.2.1","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.27","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"b66861dc101128127c053ac370814837566965ab","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.2.1.tgz","integrity":"sha512-pqvgeVXLArQ7EWNuEmT9YypS3xEyjuYmIp133dtfvnlYCfqA4KWvTmqO2fVs/f/a7Cj0K7JutN9Vukcr83ju0w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD29bjzawugv80K4r0zHFqvXuWt/QyagouDa8/xMjvedQIhAOi5M6oQVPCOBu2lzJwT+1o9qmKDBMxjWxeemBfVicB8"}]},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.2.3":{"name":"intercom","version":"0.2.3","description":"dnode-protocol and EventEmitter2 based event intercom using child_process.fork() function. Including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"git://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.12","eventemitter2":"0.4.x","node-fork":"0.1.x"},"engines":{"node":"0.4.x"},"_npmJsonOpts":{"file":"/home/sander/.npm/intercom/0.2.3/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"intercom@0.2.3","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.27","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"b8e53877934274cdd4cecabcd2a98c154ba729c5","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.2.3.tgz","integrity":"sha512-klN8uLOerKu23LmajmpECmRplW0IDGPuANZR9hvUMu+JxCDwuWhw/GVnTv3PPWMQb2oVikY+8mrqCVgylIbNyA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDmZsNFxS2pA1Ju7jFGd51eVeVKXrH2B9NZ2dMJQvbxewIhAOC9/AoPBw0pDn70F7NBoTCx2LDwim0/QS2SZkfrbnEq"}]},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.2.4":{"name":"intercom","version":"0.2.4","description":"dnode-protocol and EventEmitter2 based event intercom using child_process.fork() function. Including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"git://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.12","eventemitter2":"0.4.x","node-fork":"0.1.x"},"engines":{"node":"0.4.x"},"_npmUser":{"name":"stolsma","email":"npm@tolsma.net"},"_id":"intercom@0.2.4","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.103","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"bde5b2707a755b69fb1229f6619126772dfc6a7a","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.2.4.tgz","integrity":"sha512-Xtzp/igsQQHNoaBkoHWWvbA4F1WIapPpuQtxefn34v79Fmx6dZ1LyPc8vRFPofYDIUG/3Yyr+VXl30+8Bvn3gg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG6O5fe66PShVbNkWv5YfvKwLWwP8Ig5HmLMOIx9by+oAiEA4kXfwRWEQzeq0HpzVXYc5sDjskE+n6+CCtF3ypLIUvY="}]},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.3.0":{"name":"intercom","version":"0.3.0","description":"dnode-protocol and EventEmitter2 based event intercom using lookalike child_process.fork() function. Including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"git://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.12","eventemitter2":"0.4.x","node-fork":"0.2.x >=0.2.1"},"devDependencies":{"vows":"0.6.x >=0.6.0"},"scripts":{"test":"vows test/**/*-test.js --isolate --spec"},"engines":{"node":"0.4.x || 0.6.x"},"_npmUser":{"name":"stolsma","email":"npm@tolsma.net"},"_id":"intercom@0.3.0","_engineSupported":true,"_npmVersion":"1.0.103","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"60b9af1f01ea61d1f682722196c385290d103bc7","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.3.0.tgz","integrity":"sha512-VNLSTBjqXvC6mExRj9nBo5EOvUix/Ey/qT1GMIp+oQwMezMCOjU9Fcs7j7QvveKe0satjSoH0VVNJXs6zMGSXQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDe/T1tZAm+UN1zl3hzxUiGnjhMp27NRVjuFfnHRY6BmAiEAz25uH0Js6svT05KgcpM1c/3uyeZyUw9ko5J9XmMbhos="}]},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.3.1":{"name":"intercom","version":"0.3.1","description":"dnode-protocol and EventEmitter2 based event intercom using lookalike child_process.fork() function. Including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"git://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.12","eventemitter2":"0.4.x","node-fork":"0.3.x"},"devDependencies":{"vows":"0.6.x >=0.6.0"},"scripts":{"test":"vows test/**/*-test.js --isolate --spec"},"engines":{"node":"0.4.x || 0.6.x"},"_npmUser":{"name":"stolsma","email":"npm@tolsma.net"},"_id":"intercom@0.3.1","_engineSupported":true,"_npmVersion":"1.0.103","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"bdbc00a528d6f2f3f9446ce6da967721e3fc5848","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.3.1.tgz","integrity":"sha512-YDrj0qhZ1rRXggbrNtNS4DOyiCCykmj9H6XhbR4Yun6uLclYkVLae+I3JCS4Yw1yQyXrOdE9utiUEXnDrvcB9Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEzFayRbs5pPXWk3ZXdDLm20TcmQu3zHTInGkYn+n6k9AiBj7PkB+yk5cDenrnOP9iEC/rWNMhmBnvq7ZPFraW1zng=="}]},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.4.0":{"name":"intercom","version":"0.4.0","description":"dnode-protocol and EventEmitter2 based event intercom using lookalike child_process.fork() function. Including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"http://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.0.12","eventemitter2":"0.4.x"},"devDependencies":{"vows":"0.6.x >=0.6.0"},"scripts":{"test":"vows test/**/*-test.js --isolate --spec"},"engines":{"node":"0.8.x || 0.9.x"},"readme":"# Intercom\n\n*Create child processes with dnode-protocol based event communication over lookalike nodejs fork communication channel with monitor and control functions for the lifecycle of the created child process*\n\n# Installing Intercom\n\n`intercom` can be installed from NPM with:\n\n    npm install intercom\n\n# Using Intercom\n\nThe code almost speaks for itself: see the example directories showing visisble and invisible examples!!\n\nFollowing is a invisible example of intercom use.\n\nParent code example (intercom.js):\n\n``` javascript\nvar path = require('path'),\n    Child = require('../../lib/intercom').EventChild;\n\nvar child = Child(path.join(__dirname, 'child.js'));\n\nchild.on('stdout', function(txt) {\n  console.log('child stdout: ' + txt);\n});\n\nchild.on('stderr', function(txt) {\n  console.log('child stderr: ' + txt);\n});\n\nchild.on('child::message', function(text) {\n  console.log('Parent: Child says: ', text);\n  child.emit('parent::message', 'This is your parent!');\n});\n\nchild.on('child::quit', function() {\n  console.log('Parent: Child wants to quit!');\n  process.nextTick(function(){\n    child.stop();\n  });\n});\n\nchild.start();\n```\n\nChild code example (child.js):\n\n``` javascript\nprocess.parent.ready(function() {\n  console.log('Comms Ready, sending message!');\n  process.parent.emit('child::message', 'I am alive!');\n});\n\nprocess.parent.on('parent::message', function(text) {\n  console.log('The parent says: ', text);\n  process.nextTick(function() {\n    process.parent.emit('child::quit');\n  });\n});\n\nconsole.log('Child is setup!!');\n```\n\nOutput when run with `node example/intercom.js`:\n\n```\nchild stdout: Child is setup!!\n\nchild stdout: Comms Ready, sending message!\n\nParent: Child says:  I am alive!\nchild stdout: The parent says:  This is your parent!\n\nParent: Child wants to quit!\n```\n\n\n# Code documentation\n\n## The EventChild class\n\nThe `EventChild` class is able to fork and control the lifecycle of a child process with a dnode-protocol based event channel between parent and child process.\nEvents emitted on the `EventChild` instance created in the child process are transported to the mirror `process.parent` instance in the child process and emitted there too! \n\nThe `EventChild` class has 9 important functions:\n\n  * `constructor(script, options)` The constructor takes two arguments: `script` and `options`. The script is the script to start in the child process. The options are described in the options section.\n  * `start()` Start the target script in a new child process (if not already started) and starts up the event communication channel.\n  * `ready(readyFn)` Execute the given function when the event channel with the child is ready\n  * `emit(event, [argument1], [argument2]...[argumentx])` Emit an event on the child `process.parent` instance.\n  * `localEmit(event, [argument1], [argument2]...[argumentx])` Emit a local event on the EventChild instance. This event is not being send to the child `process.parent` instance.\n  * `on(event, callback)` React on a defined child event.\n  * `onAny(callback)`  React on any child event.\n  * `restart()`  Restarts the target script child process associated with this instance.\n  * `stop()` Stops the target script associated with this instance. Prevents it from auto-respawning.  \n  \nSee [EventEmitter2](https://github.com/hij1nx/EventEmitter2) for more information on the `emit`, `on`, `onAny` and other function standard available on EventEmitter2 classes.  \n  \n### Constructor options\n\n``` js\n  {\n    // Basic configuration options\n    'eventOptions': {           // Options for the EventEmitter2 constructor. See EventEmitter2!!\n       delimiter: '::',\n       wildcard: true\n     },\n    'forever': true,            // Indicates that this script should run forever\n    'max': 10,                  // Sets the maximum number of times a given script should run\n    \n    // These options control how quickly parent restarts a child process\n    // as well as when to kill a \"spinning\" process\n    'minUptime': 2000,          // Minimum time a child process has to be up. EventChild will 'exit' otherwise.\n    'spinSleepTime': 1000,      // Interval between restarts if a child is spinning (i.e. alive < minUptime).\n    \n    // Command to spawn as well as options and other vars \n    // (env, cwd, etc) to pass along\n    'options': ['foo','bar'],   // Additional arguments to pass to the script,\n    'sourceDir': 'script/path'  // Directory that the source script is in\n    \n    // All or nothing options passed along to `child_process.fork`.\n    'spawnWith': {\n      env: process.env,         // Information passed along to the child process environment\n      customFds: [-1, -1, -1],  // that EventChild spawns.\n      setsid: false\n    },\n    \n    // More specific options to pass along to `child_process.spawn` which \n    // will override anything passed to the `spawnWith` option\n    'env': { 'ADDITIONAL': 'CHILD ENV VARS' }\n    'cwd': '/path/to/child/working/directory'\n  }\n```\n\n### Standard events when using an instance of EventChild\n\nEach EventChild instance is an descendant of EventEmitter2. There are also several core events that you can listen for. This are also the events types you cannot use to send over de communication channel!!:\n\n* **error**    _[err, info]:_           Raised when an error occurs\n* **start**    _[child, child_data]:_   Raised when the target script is first started.\n* **stop**     _[child_data]:_          Raised when the target script is stopped by the user\n* **restart**  _[child]:_               Raised each time the target script is restarted\n* **exit**     _[child]:_               Raised when the target script actually exits (permenantly).\n* **stdout**   _[data]:_                Raised when data is received from the child process' stdout\n* **stderr**   _[data]:_                Raised when data is received from the child process' stderr\n* **warn**     _[err, info]:_           Raised when something unexpected happens but there is no need to break the codeflow\n\nThe following two events are related to the dnode-protocol RPC session:\n\n* **rpcready**  _[]:_                   Raised when the dnode-protocol RPC session is up and running and events can be send and received\n* **rpcexit**   _[]:_                   Raised when the dnode-protocol RPC session has ended. events won't be send to the child process anymore.\n\n\n## The Child Process\n\nThe `intercom` module automatically creates a dnode-protocol based event channel between parent and child process when a, by fork created, `message` event and `send()` function are detected.\nEvents emitted on the `process.parent` instance are transported to the mirror `EventChild` class in the parent process and emitted there too! \n\nThe `process.parent` instance has 5 important functions:\n\n  * `ready(readyFn)` Execute the given function when the event channel with the parent is ready\n  * `emit(event, [argument1], [argument2]...[argumentx])` Emit an event on the parent process `EventChild` instance.\n  * `localEmit(event, [argument1], [argument2]...[argumentx])` Emit a local event on the `process.parent` instance. This event is not being send to the parent `EventChild` instance.\n  * `on(event, callback)` React on a (parent) event. \n  * `onAny(callback)`  React on any (parent) events.\n  \nSee [EventEmitter2](https://github.com/hij1nx/EventEmitter2) for more information on the `emit`, `on` `onAny` and other function standard available on EventEmitter2 classes.  \n\n### Standard events when using `process.parent`\n\nEach `process.parent` instance is a descendant of EventEmitter2. There are also several core events that you can listen for. This are also the events types you cannot use to send over de communication channel!!:\n\n* **error**    _[err, info]:_           Raised when an error occurs\n* **warn**     _[err, info]:_           Raised when something unexpected happens but there is no need to break the codeflow\n\nThe following two events are related to the dnode-protocol RPC session:\n\n* **rpcready**  _[]:_                   Raised when the dnode-protocol RPC session is up and running and events can be send and received\n* **rpcexit**   _[]:_                   Raised when the dnode-protocol RPC session has ended. events won't be send to the child process anymore.\n\n\nDocumentation License\n=====================\n\nCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License\n\nhttp://creativecommons.org/licenses/by-nc-sa/3.0/\n\nCopyright (c)2011 [TTC](http://www.tolsma.net)/[Sander Tolsma](http://sander.tolsma.net/)\n\n\nCode License\n============\n\n[MIT License](http://www.opensource.org/licenses/mit-license.php)\n\nCopyright (c)2011 [TTC](http://www.tolsma.net)/[Sander Tolsma](http://sander.tolsma.net/)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.","_id":"intercom@0.4.0","dist":{"shasum":"470eba741e5f144b0bf4b787fe931c19e480d7b5","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.4.0.tgz","integrity":"sha512-xowk1KWRCmftm4yyvwaG6tgyRs8k5V/v0jT194ekc10NwKi7ang8tDIVp2a189w+FttCVMz0wGu1h5vvTpWRUw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGbFjVSslDBpmmrhplHZPWR+G40tp9iF+MswP9jZgEisAiBEeov/OvJL6Dildd8GZc52IWYen//E/2RMd6r77VCFmQ=="}]},"_npmVersion":"1.1.49","_npmUser":{"name":"stolsma","email":"npm@tolsma.net"},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.4.1":{"name":"intercom","version":"0.4.1","description":"dnode-protocol and EventEmitter2 based event intercom using lookalike child_process.fork() function. Including child process lifecycle functions based on Forever.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"http://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.2.x","eventemitter2":"0.4.x"},"devDependencies":{"vows":"0.6.x >=0.6.0"},"scripts":{"test":"vows test/**/*-test.js --isolate --spec"},"engines":{"node":"0.8.x || 0.9.x"},"readme":"# Intercom\n\n*Create child processes with dnode-protocol based event communication over the nodejs fork internal communication channel, with monitor and control functions for the lifecycle of the created child process*\n\n# Installing Intercom\n\n`intercom` can be installed from NPM with:\n\n    npm install intercom\n\n# Using Intercom\n\nThe code almost speaks for itself: see the example directories showing visisble and invisible examples!!\n\nFollowing is a invisible example of intercom use.\n\nParent code example (intercom.js):\n\n``` javascript\nvar path = require('path'),\n    Child = require('../../lib/intercom').EventChild;\n\nvar child = Child(path.join(__dirname, 'child.js'));\n\nchild.on('stdout', function(txt) {\n  console.log('child stdout: ' + txt);\n});\n\nchild.on('stderr', function(txt) {\n  console.log('child stderr: ' + txt);\n});\n\nchild.on('child::message', function(text) {\n  console.log('Parent: Child says: ', text);\n  child.emit('parent::message', 'This is your parent!');\n});\n\nchild.on('child::quit', function() {\n  console.log('Parent: Child wants to quit!');\n  process.nextTick(function(){\n    child.stop();\n  });\n});\n\nchild.start();\n```\n\nChild code example (child.js):\n\n``` javascript\nprocess.parent.ready(function() {\n  console.log('Comms Ready, sending message!');\n  process.parent.emit('child::message', 'I am alive!');\n});\n\nprocess.parent.on('parent::message', function(text) {\n  console.log('The parent says: ', text);\n  process.nextTick(function() {\n    process.parent.emit('child::quit');\n  });\n});\n\nconsole.log('Child is setup!!');\n```\n\nOutput when run with `node example/intercom.js`:\n\n```\nchild stdout: Child is setup!!\n\nchild stdout: Comms Ready, sending message!\n\nParent: Child says:  I am alive!\nchild stdout: The parent says:  This is your parent!\n\nParent: Child wants to quit!\n```\n\n\n# Code documentation\n\n## The EventChild class\n\nThe `EventChild` class is able to fork and control the lifecycle of a child process with a dnode-protocol based event channel between parent and child process.\nEvents emitted on the `EventChild` instance created in the child process are transported to the mirror `process.parent` instance in the child process and emitted there too! \n\nThe `EventChild` class has 9 important functions:\n\n  * `constructor(script, options)` The constructor takes two arguments: `script` and `options`. The script is the script to start in the child process. The options are described in the options section.\n  * `start()` Start the target script in a new child process (if not already started) and starts up the event communication channel.\n  * `ready(readyFn)` Execute the given function when the event channel with the child is ready\n  * `emit(event, [argument1], [argument2]...[argumentx])` Emit an event on the child `process.parent` instance.\n  * `localEmit(event, [argument1], [argument2]...[argumentx])` Emit a local event on the EventChild instance. This event is not being send to the child `process.parent` instance.\n  * `on(event, callback)` React on a defined child event.\n  * `onAny(callback)`  React on any child event.\n  * `restart()`  Restarts the target script child process associated with this instance.\n  * `stop()` Stops the target script associated with this instance. Prevents it from auto-respawning.  \n  \nSee [EventEmitter2](https://github.com/hij1nx/EventEmitter2) for more information on the `emit`, `on`, `onAny` and other function standard available on EventEmitter2 classes.  \n  \n### Constructor options\n\n``` js\n  {\n    // Basic configuration options\n    'eventOptions': {           // Options for the EventEmitter2 constructor. See EventEmitter2!!\n       delimiter: '::',\n       wildcard: true\n     },\n    'forever': true,            // Indicates that this script should run forever\n    'max': 10,                  // Sets the maximum number of times a given script should run\n    \n    // These options control how quickly parent restarts a child process\n    // as well as when to kill a \"spinning\" process\n    'minUptime': 2000,          // Minimum time a child process has to be up. EventChild will 'exit' otherwise.\n    'spinSleepTime': 1000,      // Interval between restarts if a child is spinning (i.e. alive < minUptime).\n    \n    // Command to spawn as well as options and other vars \n    // (env, cwd, etc) to pass along\n    'options': ['foo','bar'],   // Additional arguments to pass to the script,\n    'sourceDir': 'script/path'  // Directory that the source script is in\n    \n    // All or nothing options passed along to `child_process.fork`. See for more info the NodeJS documentation.\n    'spawnWith': {\n      env: process.env          // Information passed along to the child process environment\n    },\n    \n    // More specific options to pass along to `child_process.spawn` which \n    // will override anything passed to the `spawnWith` option\n    'env': { 'ADDITIONAL': 'CHILD ENV VARS' }\n    'cwd': '/path/to/child/working/directory'\n  }\n```\n\n### Standard events when using an instance of EventChild\n\nEach EventChild instance is an descendant of EventEmitter2. There are also several core events that you can listen for. This are also the events types you cannot use to send over de communication channel!!:\n\n* **error**    _[err, info]:_           Raised when an error occurs\n* **start**    _[child, child_data]:_   Raised when the target script is first started.\n* **stop**     _[child_data]:_          Raised when the target script is stopped by the user\n* **restart**  _[child]:_               Raised each time the target script is restarted\n* **exit**     _[child]:_               Raised when the target script actually exits (permenantly).\n* **stdout**   _[data]:_                Raised when data is received from the child process' stdout\n* **stderr**   _[data]:_                Raised when data is received from the child process' stderr\n* **warn**     _[err, info]:_           Raised when something unexpected happens but there is no need to break the codeflow\n\nThe following two events are related to the dnode-protocol RPC session:\n\n* **rpcready**  _[]:_                   Raised when the dnode-protocol RPC session is up and running and events can be send and received\n* **rpcexit**   _[]:_                   Raised when the dnode-protocol RPC session has ended. events won't be send to the child process anymore.\n\n\n## The Child Process\n\nThe `intercom` module automatically creates a dnode-protocol based event channel between parent and child process when a, by fork created, `message` event and `send()` function are detected.\nEvents emitted on the `process.parent` instance are transported to the mirror `EventChild` class in the parent process and emitted there too! \n\nThe `process.parent` instance has 5 important functions:\n\n  * `ready(readyFn)` Execute the given function when the event channel with the parent is ready\n  * `emit(event, [argument1], [argument2]...[argumentx])` Emit an event on the parent process `EventChild` instance.\n  * `localEmit(event, [argument1], [argument2]...[argumentx])` Emit a local event on the `process.parent` instance. This event is not being send to the parent `EventChild` instance.\n  * `on(event, callback)` React on a (parent) event. \n  * `onAny(callback)`  React on any (parent) events.\n  \nSee [EventEmitter2](https://github.com/hij1nx/EventEmitter2) for more information on the `emit`, `on` `onAny` and other function standard available on EventEmitter2 classes.  \n\n### Standard events when using `process.parent`\n\nEach `process.parent` instance is a descendant of EventEmitter2. There are also several core events that you can listen for. This are also the events types you cannot use to send over de communication channel!!:\n\n* **error**    _[err, info]:_           Raised when an error occurs\n* **warn**     _[err, info]:_           Raised when something unexpected happens but there is no need to break the codeflow\n\nThe following two events are related to the dnode-protocol RPC session:\n\n* **rpcready**  _[]:_                   Raised when the dnode-protocol RPC session is up and running and events can be send and received\n* **rpcexit**   _[]:_                   Raised when the dnode-protocol RPC session has ended. events won't be send to the child process anymore.\n\n\nDocumentation License\n=====================\n\nCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License\n\nhttp://creativecommons.org/licenses/by-nc-sa/3.0/\n\nCopyright (c)2011 [TTC](http://www.tolsma.net)/[Sander Tolsma](http://sander.tolsma.net/)\n\n\nCode License\n============\n\n[MIT License](http://www.opensource.org/licenses/mit-license.php)\n\nCopyright (c)2011 [TTC](http://www.tolsma.net)/[Sander Tolsma](http://sander.tolsma.net/)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.","_id":"intercom@0.4.1","dist":{"shasum":"224c9f87d17047a0f9e89b1c6bab0f53696d00f4","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.4.1.tgz","integrity":"sha512-1Wom3uX+bWkj2z9bD+/kmcwMMoUL6OJBEfqduiLR29jM9lJlhE4cDeqxSIfFxenE1MA2Qvgh76hGZkNYaa1nnw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID6T0TjjovE08DE7dzbokbp3cYwFwei8qZPW7lSX14QFAiEAoXuL24evBpYe3SnOhR+AAF2yUtUq6TLK938GKagWgzE="}]},"_npmVersion":"1.1.49","_npmUser":{"name":"stolsma","email":"npm@tolsma.net"},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.5.0":{"name":"intercom","version":"0.5.0","description":"Create child processes with dnode-protocol based event communication over the nodejs IPC channel, with monitor and control functions for the lifecycle of the created child process.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"http://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.2.x","eventemitter2":"0.4.x"},"devDependencies":{"vows":"0.6.x >=0.6.0"},"scripts":{"test":"vows test/**/*-test.js --isolate --spec"},"engines":{"node":"0.8.x || 0.9.x"},"readme":"# Intercom\n\n*Create child processes with dnode-protocol based event communication over the nodejs IPC channel, with monitor and control functions for the lifecycle of the created child process*\n\nImportant: per Intercom version 0.5.0 the behavior of the 'exit' event changed!!! Added is the 'close' event as direct replacement for the old 'exit' event. See below for more information.\n\n# Installing Intercom\n\n`intercom` can be installed from NPM with:\n\n    npm install intercom\n\n# Using Intercom\n\nThe code almost speaks for itself: see the example directories showing visisble and invisible examples!!\n\nFollowing is a invisible example of intercom use.\n\nParent code example (intercom.js):\n\n``` javascript\nvar path = require('path'),\n    Child = require('../../lib/intercom').EventChild;\n\nvar child = Child(path.join(__dirname, 'child.js'));\n\nchild.on('stdout', function(txt) {\n  console.log('child stdout: ' + txt);\n});\n\nchild.on('stderr', function(txt) {\n  console.log('child stderr: ' + txt);\n});\n\nchild.on('child::message', function(text) {\n  console.log('Parent: Child says: ', text);\n  child.emit('parent::message', 'This is your parent!');\n});\n\nchild.on('child::quit', function() {\n  console.log('Parent: Child wants to quit!');\n  process.nextTick(function(){\n    child.stop();\n  });\n});\n\nchild.start();\n```\n\nChild code example (child.js):\n\n``` javascript\nprocess.parent.ready(function() {\n  console.log('Comms Ready, sending message!');\n  process.parent.emit('child::message', 'I am alive!');\n});\n\nprocess.parent.on('parent::message', function(text) {\n  console.log('The parent says: ', text);\n  process.nextTick(function() {\n    process.parent.emit('child::quit');\n  });\n});\n\nconsole.log('Child is setup!!');\n```\n\nOutput when run with `node example/visible/intercom.js`:\n\n```\nchild stdout: Child is setup!!\n\nchild stdout: Comms Ready, sending message!\n\nParent: Child says:  I am alive!\nchild stdout: The parent says:  This is your parent!\n\nParent: Child wants to quit!\n```\n\n\n# Code documentation\n\n## The EventChild class\n\nThe `EventChild` class is able to fork and control the lifecycle of a child process with a dnode-protocol based event channel between parent and child process.\nEvents emitted on the `EventChild` instance created in the child process are transported to the mirror `process.parent` instance in the child process and emitted there too! \n\nThe `EventChild` class has 9 important functions:\n\n  * `constructor(script, options)` The constructor takes two arguments: `script` and `options`. The script is the script to start in the child process. The options are described in the options section.\n  * `start()` Start the target script in a new child process (if not already started) and starts up the event communication channel.\n  * `ready(readyFn)` Execute the given function when the event channel with the child is ready\n  * `emit(event, [argument1], [argument2]...[argumentx])` Emit an event on the child `process.parent` instance.\n  * `localEmit(event, [argument1], [argument2]...[argumentx])` Emit a local event on the EventChild instance. This event is not being send to the child `process.parent` instance.\n  * `on(event, callback)` React on a defined child event.\n  * `onAny(callback)`  React on any child event.\n  * `restart()`  Restarts the target script child process associated with this instance.\n  * `stop()` Stops the target script associated with this instance. Prevents it from auto-respawning.  \n  * `disconnect()` Disconnects and closes the IPC channel and the RPC session but lets the child running.  \n  \nSee [EventEmitter2](https://github.com/hij1nx/EventEmitter2) for more information on the `emit`, `on`, `onAny` and other function standard available on EventEmitter2 classes.  \n  \n### Constructor options\n\n``` js\n  {\n    // Basic configuration options\n    'eventOptions': {           // Options for the EventEmitter2 constructor. See EventEmitter2!!\n       delimiter: '::',\n       wildcard: true\n     },\n    'max': 10,                  // Sets the maximum number of times a given script should run (undefined = forever)\n    \n    // These options control how quickly parent restarts a child process\n    // as well as when to kill a \"spinning\" process\n    'minUptime': 2000,          // Minimum time a child process has to be up. EventChild will 'exit' otherwise.\n    'spinSleepTime': 1000,      // Interval between restarts if a child is spinning (i.e. alive < minUptime).\n    \n    // Command to spawn as well as options and other vars \n    // (env, cwd, etc) to pass along\n    'options': ['foo','bar'],   // Additional arguments to pass to the script,\n    'sourceDir': 'script/path'  // Directory that the source script is in\n    \n    // All or nothing options passed along to `child_process.fork`. See for more info the NodeJS documentation.\n    'spawnWith': {},\n    \n    // More specific options to pass along to `child_process.spawn` which \n    // will override anything passed to the `spawnWith` option\n    'env': { 'ADDITIONAL': 'CHILD ENV VARS' }\n    'cwd': '/path/to/child/working/directory'\n    'silent': true,             // Silences the output from stdout and stderr in the parent process\n  }\n```\n\n### Standard events when using an instance of EventChild\n\nEach EventChild instance is an descendant of EventEmitter2. There are also several core events that you can listen for. This are also the events types you cannot use to send over de communication channel!!:\n\n* **error**         _[err, info]:_              Raised when an error occurs\n* **start**         _[child_data]:_             Raised when the target script is first started\n* **stop**          _[child_data]:_             Raised when the target script is stopped by the user\n* **restart**       _[child_data]:_             Raised each time the target script is restarted\n* **exit**          _[code, signal]:_           Raised when the target script process actually exits (before restart dec\n* **close**         _[spinning, code, signal]_  Raised when the target script actually exits permenantly.\n* **disconnect**    _[]_                        Raised when disconnection from the IPC channel is requested\n* **disconnected**  _[]_                        Raised when the IPC channel is disconnected\n* **stdout**        _[data]:_                   Raised when data is received from the child process' stdout\n* **stderr**        _[data]:_                   Raised when data is received from the child process' stderr\n* **warn**          _[err, info]:_              Raised when something unexpected happens but there's no need to break the codeflow\n\n\nThe following two events are related to the dnode-protocol RPC session:\n\n* **rpcready**      _[]:_                       Raised when the dnode-protocol RPC session is up and running and events can be send and received\n* **rpcexit**       _[]:_                       Raised when the dnode-protocol RPC session has ended. events won't be send to the child process anymore.\n\n\n## The Child Process\n\nThe `intercom` module automatically creates a dnode-protocol based event channel between parent and child process when a, by fork created, `message` event and `send()` function are detected.\nEvents emitted on the `process.parent` instance are transported to the mirror `EventChild` class in the parent process and emitted there too! \n\nThe `process.parent` instance has 5 important functions:\n\n  * `ready(readyFn)` Execute the given function when the event channel with the parent is ready\n  * `emit(event, [argument1], [argument2]...[argumentx])` Emit an event on the parent process `EventChild` instance.\n  * `localEmit(event, [argument1], [argument2]...[argumentx])` Emit a local event on the `process.parent` instance. This event is not being send to the parent `EventChild` instance.\n  * `on(event, callback)` React on a (parent) event. \n  * `onAny(callback)`  React on any (parent) events.\n  * `disconnect()` Disconnects and closes the IPC channel and the RPC session but lets the child running until its done or `exit` is called .  \n  \nSee [EventEmitter2](https://github.com/hij1nx/EventEmitter2) for more information on the `emit`, `on` `onAny` and other function standard available on EventEmitter2 classes.  \n\n### Standard events when using `process.parent`\n\nEach `process.parent` instance is a descendant of EventEmitter2. There are also several core events that you can listen for. This are also the events types you cannot use to send over de communication channel!!:\n\n* **disconnect**    _[]_                        Raised when disconnection from the IPC channel is requested\n* **disconnected**  _[]_                        Raised when the IPC channel is disconnected\n* **error**         _[err, info]:_              Raised when an error occurs\n* **warn**          _[err, info]:_              Raised when something unexpected happens but there is no need to break the codeflow\n\nThe following two events are related to the dnode-protocol RPC session:\n\n* **rpcready**      _[]:_                       Raised when the dnode-protocol RPC session is up and running and events can be send and received\n* **rpcexit**       _[]:_                       Raised when the dnode-protocol RPC session has ended. events won't be send to the child process anymore.\n\n\nDocumentation License\n=====================\n\nCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License\n\nhttp://creativecommons.org/licenses/by-nc-sa/3.0/\n\nCopyright (c)2011 [TTC](http://www.tolsma.net)/[Sander Tolsma](http://sander.tolsma.net/)\n\n\nCode License\n============\n\n[MIT License](http://www.opensource.org/licenses/mit-license.php)\n\nCopyright (c)2011 [TTC](http://www.tolsma.net)/[Sander Tolsma](http://sander.tolsma.net/)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.","_id":"intercom@0.5.0","dist":{"shasum":"fd20542be1b1bf29a178c994bc37b0338028a0c4","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.5.0.tgz","integrity":"sha512-czlEs+mJliR4+KltgiZVyBFQ2FeAs+zvJEXrOvl4uSyb/94QAgZT+Igx4DUcFSvjVLshT0x5znQnAOgGV7dMzQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBiiMPIJzPmYLCLQXagCzTdat8oE89EPBwJ8pk50nclNAiAcb4JNuEpt11ZlsZ5UJrM2QrrJHjyNltqb0X09/c52tw=="}]},"_npmVersion":"1.1.49","_npmUser":{"name":"stolsma","email":"npm@tolsma.net"},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]},"0.5.1":{"name":"intercom","version":"0.5.1","description":"Create child processes with dnode-protocol based event communication over the nodejs IPC channel, with monitor and control functions for the lifecycle of the created child process.","author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"http://github.com/stolsma/intercom.git"},"main":"./lib/intercom","dependencies":{"dnode-protocol":"0.2.x","eventemitter2":"0.4.x"},"devDependencies":{"vows":"0.6.x >=0.6.0"},"scripts":{"test":"vows test/**/*-test.js --isolate --spec"},"engines":{"node":"0.8.x || 0.9.x"},"readme":"# Intercom\n\n*Create child processes with dnode-protocol based event communication over the nodejs IPC channel, with monitor and control functions for the lifecycle of the created child process*\n\nImportant: per Intercom version 0.5.0 the behavior of the 'exit' event changed!!! Added is the 'close' event as direct replacement for the old 'exit' event. See below for more information.\n\n# Installing Intercom\n\n`intercom` can be installed from NPM with:\n\n    npm install intercom\n\n# Using Intercom\n\nThe code almost speaks for itself: see the example directories showing visisble and invisible examples!!\n\nFollowing is a invisible example of intercom use.\n\nParent code example (intercom.js):\n\n``` javascript\nvar path = require('path'),\n    Child = require('../../lib/intercom').EventChild;\n\nvar child = Child(path.join(__dirname, 'child.js'));\n\nchild.on('stdout', function(txt) {\n  console.log('child stdout: ' + txt);\n});\n\nchild.on('stderr', function(txt) {\n  console.log('child stderr: ' + txt);\n});\n\nchild.on('child::message', function(text) {\n  console.log('Parent: Child says: ', text);\n  child.emit('parent::message', 'This is your parent!');\n});\n\nchild.on('child::quit', function() {\n  console.log('Parent: Child wants to quit!');\n  process.nextTick(function(){\n    child.stop();\n  });\n});\n\nchild.start();\n```\n\nChild code example (child.js):\n\n``` javascript\nprocess.parent.ready(function() {\n  console.log('Comms Ready, sending message!');\n  process.parent.emit('child::message', 'I am alive!');\n});\n\nprocess.parent.on('parent::message', function(text) {\n  console.log('The parent says: ', text);\n  process.nextTick(function() {\n    process.parent.emit('child::quit');\n  });\n});\n\nconsole.log('Child is setup!!');\n```\n\nOutput when run with `node example/visible/intercom.js`:\n\n```\nchild stdout: Child is setup!!\n\nchild stdout: Comms Ready, sending message!\n\nParent: Child says:  I am alive!\nchild stdout: The parent says:  This is your parent!\n\nParent: Child wants to quit!\n```\n\n\n# Code documentation\n\n## The EventChild class\n\nThe `EventChild` class is able to fork and control the lifecycle of a child process with a dnode-protocol based event channel between parent and child process.\nEvents emitted on the `EventChild` instance created in the child process are transported to the mirror `process.parent` instance in the child process and emitted there too! \n\nThe `EventChild` class has 9 important functions:\n\n  * `constructor(script, options)` The constructor takes two arguments: `script` and `options`. The script is the script to start in the child process. The options are described in the options section.\n  * `start()` Start the target script in a new child process (if not already started) and starts up the event communication channel.\n  * `ready(readyFn)` Execute the given function when the event channel with the child is ready\n  * `emit(event, [argument1], [argument2]...[argumentx])` Emit an event on the child `process.parent` instance.\n  * `localEmit(event, [argument1], [argument2]...[argumentx])` Emit a local event on the EventChild instance. This event is not being send to the child `process.parent` instance.\n  * `on(event, callback)` React on a defined child event.\n  * `onAny(callback)`  React on any child event.\n  * `restart()`  Restarts the target script child process associated with this instance.\n  * `stop()` Stops the target script associated with this instance. Prevents it from auto-respawning.  \n  * `disconnect()` Disconnects and closes the IPC channel and the RPC session but lets the child running.  \n  \nSee [EventEmitter2](https://github.com/hij1nx/EventEmitter2) for more information on the `emit`, `on`, `onAny` and other function standard available on EventEmitter2 classes.  \n  \n### Constructor options\n\n``` js\n  {\n    // Basic configuration options\n    'eventOptions': {           // Options for the EventEmitter2 constructor. See EventEmitter2!!\n       delimiter: '::',\n       wildcard: true\n     },\n    'max': 10,                  // Sets the maximum number of times a given script should run (undefined = forever)\n    \n    // These options control how quickly parent restarts a child process\n    // as well as when to kill a \"spinning\" process\n    'minUptime': 2000,          // Minimum time a child process has to be up. EventChild will 'exit' otherwise.\n    'spinSleepTime': 1000,      // Interval between restarts if a child is spinning (i.e. alive < minUptime).\n    \n    // Command to spawn as well as options and other vars \n    // (env, cwd, etc) to pass along\n    'options': ['foo','bar'],   // Additional arguments to pass to the script,\n    'sourceDir': 'script/path'  // Directory that the source script is in\n    \n    // All or nothing options passed along to `child_process.fork`. See for more info the NodeJS documentation.\n    'spawnWith': {},\n    \n    // More specific options to pass along to `child_process.spawn` which \n    // will override anything passed to the `spawnWith` option\n    'env': { 'ADDITIONAL': 'CHILD ENV VARS' }\n    'cwd': '/path/to/child/working/directory'\n    'silent': true,             // Silences the output from stdout and stderr in the parent process\n  }\n```\n\n### Standard events when using an instance of EventChild\n\nEach EventChild instance is an descendant of EventEmitter2. There are also several core events that you can listen for. This are also the events types you cannot use to send over de communication channel!!:\n\n* **error**         _[err, info]:_              Raised when an error occurs\n* **start**         _[child_data]:_             Raised when the target script is first started\n* **stop**          _[child_data]:_             Raised when the target script is stopped by the user\n* **restart**       _[child_data]:_             Raised each time the target script is restarted\n* **exit**          _[code, signal]:_           Raised when the target script process actually exits (before restart dec\n* **close**         _[spinning, code, signal]_  Raised when the target script actually exits permenantly.\n* **disconnect**    _[]_                        Raised when disconnection from the IPC channel is requested\n* **disconnected**  _[]_                        Raised when the IPC channel is disconnected\n* **stdout**        _[data]:_                   Raised when data is received from the child process' stdout\n* **stderr**        _[data]:_                   Raised when data is received from the child process' stderr\n* **warn**          _[err, info]:_              Raised when something unexpected happens but there's no need to break the codeflow\n\n\nThe following two events are related to the dnode-protocol RPC session:\n\n* **rpcready**      _[]:_                       Raised when the dnode-protocol RPC session is up and running and events can be send and received\n* **rpcexit**       _[]:_                       Raised when the dnode-protocol RPC session has ended. events won't be send to the child process anymore.\n\n\n## The Child Process\n\nThe `intercom` module automatically creates a dnode-protocol based event channel between parent and child process when a, by fork created, `message` event and `send()` function are detected.\nEvents emitted on the `process.parent` instance are transported to the mirror `EventChild` class in the parent process and emitted there too! \n\nThe `process.parent` instance has 5 important functions:\n\n  * `ready(readyFn)` Execute the given function when the event channel with the parent is ready\n  * `emit(event, [argument1], [argument2]...[argumentx])` Emit an event on the parent process `EventChild` instance.\n  * `localEmit(event, [argument1], [argument2]...[argumentx])` Emit a local event on the `process.parent` instance. This event is not being send to the parent `EventChild` instance.\n  * `on(event, callback)` React on a (parent) event. \n  * `onAny(callback)`  React on any (parent) events.\n  * `disconnect()` Disconnects and closes the IPC channel and the RPC session but lets the child running until its done or `exit` is called .  \n  \nSee [EventEmitter2](https://github.com/hij1nx/EventEmitter2) for more information on the `emit`, `on` `onAny` and other function standard available on EventEmitter2 classes.  \n\n### Standard events when using `process.parent`\n\nEach `process.parent` instance is a descendant of EventEmitter2. There are also several core events that you can listen for. This are also the events types you cannot use to send over de communication channel!!:\n\n* **disconnect**    _[]_                        Raised when disconnection from the IPC channel is requested\n* **disconnected**  _[]_                        Raised when the IPC channel is disconnected\n* **error**         _[err, info]:_              Raised when an error occurs\n* **warn**          _[err, info]:_              Raised when something unexpected happens but there is no need to break the codeflow\n\nThe following two events are related to the dnode-protocol RPC session:\n\n* **rpcready**      _[]:_                       Raised when the dnode-protocol RPC session is up and running and events can be send and received\n* **rpcexit**       _[]:_                       Raised when the dnode-protocol RPC session has ended. events won't be send to the child process anymore.\n\n\nDocumentation License\n=====================\n\nCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License\n\nhttp://creativecommons.org/licenses/by-nc-sa/3.0/\n\nCopyright (c)2011 [TTC](http://www.tolsma.net)/[Sander Tolsma](http://sander.tolsma.net/)\n\n\nCode License\n============\n\n[MIT License](http://www.opensource.org/licenses/mit-license.php)\n\nCopyright (c)2011 [TTC](http://www.tolsma.net)/[Sander Tolsma](http://sander.tolsma.net/)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.","_id":"intercom@0.5.1","dist":{"shasum":"622618fc74a4385b390652092842d08f57d7bd4f","tarball":"https://registry.npmjs.org/intercom/-/intercom-0.5.1.tgz","integrity":"sha512-HylJuEbeDn4NbDQqaf31DmAnVuzDFdrxCoQ1W1hjr1Mqqftal2zCH5QhAO3EA3lptJdboziIy9q6rn6Z5MYd8g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCm9UIbUmmbnMgmp7Y6Y1C3kYccfZ3GY+CnQGFtR3VVRgIhAKadYYnvwTUVKGfCRv+cGe2225ZTmNX2w6cixi/KxuRj"}]},"_npmVersion":"1.1.49","_npmUser":{"name":"stolsma","email":"npm@tolsma.net"},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}]}},"maintainers":[{"name":"stolsma","email":"npm@tolsma.net"}],"time":{"modified":"2022-06-19T01:44:10.191Z","created":"2011-10-05T18:18:38.011Z","0.1.1":"2011-10-05T18:18:39.642Z","0.1.2":"2011-10-14T08:07:12.965Z","0.1.3":"2011-10-15T18:46:59.745Z","0.2.0":"2011-10-16T08:14:50.620Z","0.2.1":"2011-10-16T08:34:58.290Z","0.2.3":"2011-10-17T20:19:34.852Z","0.2.4":"2011-10-27T06:27:44.392Z","0.3.0":"2011-12-13T22:07:18.778Z","0.3.1":"2012-01-05T21:49:42.547Z","0.4.0":"2012-08-22T15:21:24.586Z","0.4.1":"2012-08-27T15:09:29.277Z","0.5.0":"2012-09-02T22:22:02.856Z","0.5.1":"2012-09-03T11:44:17.533Z"},"author":{"name":"Sander Tolsma","email":"sander at tolsma.net"},"repository":{"type":"git","url":"http://github.com/stolsma/intercom.git"},"users":{"stringparser":true}}