{"_id":"pm2-interface","_rev":"2772373","name":"pm2-interface","description":"Interact with pm2 via RPC and receive real time notifications","dist-tags":{"latest":"2.0.4"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"time":{"modified":"2022-05-23T09:41:15.000Z","created":"2013-11-12T09:59:22.598Z","2.0.4":"2014-10-11T13:19:12.438Z","2.0.3":"2014-09-30T12:18:21.792Z","2.0.2":"2014-09-30T10:14:01.064Z","2.0.1":"2014-09-18T17:17:19.572Z","1.1.0":"2014-08-18T13:29:59.246Z","0.1.3":"2014-05-15T12:28:22.930Z","0.1.2":"2014-05-15T12:26:42.516Z","0.1.1":"2014-04-09T06:43:48.167Z","0.1.0":"2014-01-06T17:16:41.260Z","0.0.3":"2013-12-20T01:57:30.024Z","0.0.2":"2013-11-22T13:22:29.495Z","0.0.1":"2013-11-12T09:59:22.598Z"},"users":{},"author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"versions":{"2.0.4":{"name":"pm2-interface","version":"2.0.4","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"pm2-axon":"2.0.7","pm2-axon-rpc":"0.3.6","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","gitHead":"ceb2b349baed87d9fbe0f762a36c56f103015d56","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"homepage":"https://github.com/Unitech/pm2-interface","_id":"pm2-interface@2.0.4","scripts":{},"_shasum":"9d552ccfe1572debb87884cf86e1bf36246c7506","_from":".","_npmVersion":"2.0.0","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"dist":{"shasum":"9d552ccfe1572debb87884cf86e1bf36246c7506","size":4528,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-2.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-2.0.4.tgz"},"directories":{},"publish_time":1413033552438,"_hasShrinkwrap":false,"_cnpm_publish_time":1413033552438,"_cnpmcore_publish_time":"2021-12-17T00:32:16.589Z"},"2.0.3":{"name":"pm2-interface","version":"2.0.3","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"pm2-axon":"2.0.5","pm2-axon-rpc":"0.3.4","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","gitHead":"ceb2b349baed87d9fbe0f762a36c56f103015d56","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"homepage":"https://github.com/Unitech/pm2-interface","_id":"pm2-interface@2.0.3","scripts":{},"_shasum":"d61e13b58b85565de88f3bbe0ce3c1d7e5708a73","_from":".","_npmVersion":"2.0.0","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"dist":{"shasum":"d61e13b58b85565de88f3bbe0ce3c1d7e5708a73","size":4527,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-2.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-2.0.3.tgz"},"directories":{},"publish_time":1412079501792,"_hasShrinkwrap":false,"_cnpm_publish_time":1412079501792,"_cnpmcore_publish_time":"2021-12-17T00:32:16.800Z"},"2.0.2":{"name":"pm2-interface","version":"2.0.2","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"pm2-axon":"2.0.4","pm2-axon-rpc":"0.3.4","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","gitHead":"a57e21e6b89cec0e8ef70d899f48422367a7817a","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"homepage":"https://github.com/Unitech/pm2-interface","_id":"pm2-interface@2.0.2","scripts":{},"_shasum":"7ab1054fe6bce882bea3bb33760c05e6f1be817c","_from":".","_npmVersion":"2.0.0","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"dist":{"shasum":"7ab1054fe6bce882bea3bb33760c05e6f1be817c","size":4527,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-2.0.2.tgz"},"directories":{},"publish_time":1412072041064,"_hasShrinkwrap":false,"_cnpm_publish_time":1412072041064,"_cnpmcore_publish_time":"2021-12-17T00:32:17.005Z"},"2.0.1":{"name":"pm2-interface","version":"2.0.1","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"pm2-axon":"2.0.2","pm2-axon-rpc":"0.3.3","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"homepage":"https://github.com/Unitech/pm2-interface","_id":"pm2-interface@2.0.1","_shasum":"9ea74126e8433ecd3b07c4d32b2baeec8e7e7c97","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"dist":{"shasum":"9ea74126e8433ecd3b07c4d32b2baeec8e7e7c97","size":4525,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-2.0.1.tgz"},"directories":{},"publish_time":1411060639572,"_hasShrinkwrap":false,"_cnpm_publish_time":1411060639572,"_cnpmcore_publish_time":"2021-12-17T00:32:17.225Z"},"1.1.0":{"name":"pm2-interface","version":"1.1.0","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"axon":"2.0.0","pm2-axon-rpc":"~0.2.0","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"homepage":"https://github.com/Unitech/pm2-interface","_id":"pm2-interface@1.1.0","scripts":{},"_shasum":"71b41b3b4d08e59b9ee409043d8a062cf5be0d67","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"dist":{"shasum":"71b41b3b4d08e59b9ee409043d8a062cf5be0d67","size":4428,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-1.1.0.tgz"},"directories":{},"publish_time":1408368599246,"_hasShrinkwrap":false,"_cnpm_publish_time":1408368599246,"_cnpmcore_publish_time":"2021-12-17T00:32:17.441Z"},"0.1.3":{"name":"pm2-interface","version":"0.1.3","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"axon":"1.0.0","pm2-axon-rpc":"0.0.2","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"homepage":"https://github.com/Unitech/pm2-interface","_id":"pm2-interface@0.1.3","dist":{"shasum":"43ef817ee829fa293f61d1d8e176b53a52407e23","size":4468,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-0.1.3.tgz"},"_from":".","_npmVersion":"1.3.22","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"directories":{},"publish_time":1400156902930,"_hasShrinkwrap":false,"_cnpm_publish_time":1400156902930,"_cnpmcore_publish_time":"2021-12-17T00:32:17.782Z"},"0.1.2":{"name":"pm2-interface","version":"0.1.2","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"axon":"1.0.0","pm2-axon-rpc":"0.0.2","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"homepage":"https://github.com/Unitech/pm2-interface","_id":"pm2-interface@0.1.2","dist":{"shasum":"7a85a8d4e0b1362b2ee01496f230b85b1cf3756c","size":4470,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-0.1.2.tgz"},"_from":".","_npmVersion":"1.3.22","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"directories":{},"publish_time":1400156802516,"_hasShrinkwrap":false,"_cnpm_publish_time":1400156802516,"_cnpmcore_publish_time":"2021-12-17T00:32:17.998Z"},"0.1.1":{"name":"pm2-interface","version":"0.1.1","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"axon":"1.0.0","axon-rpc":"0.0.2","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"homepage":"https://github.com/Unitech/pm2-interface","_id":"pm2-interface@0.1.1","dist":{"shasum":"204d78b2cd1472e31a003185d46edc7a10e9c535","size":4470,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-0.1.1.tgz"},"_from":".","_npmVersion":"1.3.22","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"directories":{},"publish_time":1397025828167,"_hasShrinkwrap":false,"_cnpm_publish_time":1397025828167,"_cnpmcore_publish_time":"2021-12-17T00:32:18.201Z"},"0.1.0":{"name":"pm2-interface","version":"0.1.0","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"axon":"1.0.0","axon-rpc":"0.0.2","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","readmeFilename":"README.md","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"_id":"pm2-interface@0.1.0","dist":{"shasum":"50de3439c8721289d831054b9e1ec6b9a57000ff","size":4451,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-0.1.0.tgz"},"_from":".","_npmVersion":"1.2.21","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"directories":{},"publish_time":1389028601260,"_hasShrinkwrap":false,"_cnpm_publish_time":1389028601260,"_cnpmcore_publish_time":"2021-12-17T00:32:18.481Z"},"0.0.3":{"name":"pm2-interface","version":"0.0.3","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"axon":"1.0.0","axon-rpc":"0.0.2","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","readmeFilename":"README.md","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"_id":"pm2-interface@0.0.3","dist":{"shasum":"3654ed17f90ccf4c808f3eb75cd09cd374dc211d","size":3629,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-0.0.3.tgz"},"_from":".","_npmVersion":"1.2.21","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"directories":{},"publish_time":1387504650024,"_hasShrinkwrap":false,"_cnpm_publish_time":1387504650024,"_cnpmcore_publish_time":"2021-12-17T00:32:19.065Z"},"0.0.2":{"name":"pm2-interface","version":"0.0.2","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"axon":"1.0.0","axon-rpc":"0.0.2","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","readmeFilename":"README.md","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"_id":"pm2-interface@0.0.2","dist":{"shasum":"07290deac2901b49380c57b78ac6a190fe0ac4cd","size":3433,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-0.0.2.tgz"},"_from":".","_npmVersion":"1.2.21","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"directories":{},"publish_time":1385126549495,"_hasShrinkwrap":false,"_cnpm_publish_time":1385126549495,"_cnpmcore_publish_time":"2021-12-17T00:32:19.368Z"},"0.0.1":{"name":"pm2-interface","version":"0.0.1","description":"Interact with pm2 via RPC and receive real time notifications","author":{"name":"Strzelewicz Alexandre","email":"as@unitech.io","url":"http://unitech.io"},"engines":{"node":">=0.8"},"main":"index.js","dependencies":{"axon":"1.0.0","axon-rpc":"0.0.2","debug":"*"},"keywords":["cli","fault tolerant","sysadmin","tools","pm2","node-pm2","monitoring","process manager","forever","process configuration","clustering","cluster cli","cluster","cron","devops","dev ops"],"repository":{"type":"git","url":"git://github.com/Unitech/pm2-interface.git"},"license":"Apache v2","readmeFilename":"README.md","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"_id":"pm2-interface@0.0.1","dist":{"shasum":"ef80c592791b6d78f24bf0e19df8932963e02747","size":2990,"noattachment":false,"key":"/pm2-interface/-/pm2-interface-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pm2-interface/download/pm2-interface-0.0.1.tgz"},"_from":".","_npmVersion":"1.2.21","_npmUser":{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"},"maintainers":[{"name":"tknew","email":"strzelewicz.alexandre@gmail.com"}],"directories":{},"publish_time":1384250362598,"_hasShrinkwrap":false,"_cnpm_publish_time":1384250362598,"_cnpmcore_publish_time":"2021-12-17T00:32:19.602Z"}},"readme":"# pm2-interface (for pm2 version >= 0.6.0)\n\npm2-interface permits you to interact with [PM2](https://github.com/Unitech/pm2) the process manager for NodeJS.\n\nYou can **control all exposed methods** by the pm2 deamon [God](https://github.com/Unitech/pm2/blob/master/lib/God.js) and also **receive real time notifications** for example for a process who got an unexpectedException, who's starting/stopping.\n\n## RPC methods\n\n- `ipm2.rpc.prepareJson(json_app, cwd, fn)` send a JSON configuration to start app(s) in the cwd folder\n- `ipm2.rpc.getMonitorData({}, fn)` receive all related informations about supervised process (cpu/ram/pid...)\n- `ipm2.rpc.getSystemData({}, fn)` receive all data about process managed by pm2 and computer resources usage\n- `ipm2.rpc.startProcessId(integer, fn)` start a process by id (pm_id) who his state is stopped\n- `ipm2.rpc.stopProcessId(integer, fn)` stop a process by id (pm_id)\n- `ipm2.rpc.stopAll({}, fn)` stop all process\n- `ipm2.rpc.reload(data, fn)` reload all apps (only for networked apps)\n- `ipm2.rpc.killMe(data, fn)` kill pm2 daemon\n- `ipm2.rpc.findByScript(string, fn)` send you back the informations about a specific process\n- `ipm2.rpc.restartProcessId(integer, fn)` restart a process by id (pm_id)\n- `ipm2.rpc.restartProcessName(string, fn)` restart all processes who have the given name\n- `ipm2.rpc.deleteProcess(string, fn)` stop and delete all processes from the pm2 database\n- `ipm2.rpc.deleteAll(data, fn)` stop and delete all processes\n- `ipm2.rpc.msgProcess(opts, fn)` send msg `opts.msg` to process at `opts.id` or all processes with `opts.name`\n\n## Notifications\n\n- `process:online` when a process is started/restarted\n- `process:exit` when a process is exited\n- `process:exception` When a process has received an uncaughtException\n\n**Advanced feature** : You can use `process.send({ type : 'my:message', data : {}})` in your Node apps. When you emit a message, they will be redirected to pm2 and sent back to the pm2-interface bus. This can be coupled with `rpc.msgProcess(opts, fn)` to allow 2-way communication between managed processes and pm2-interface - see second Example below.\n\n> It should be noted that `process.send` will be undefined if there is no parent process. Therefore a check of `if (process.send)` may be advisable.\n\n## Example\n\n```javascript\nvar ipm2 = require('pm2-interface')();\n\nipm2.on('ready', function() {\n  console.log('Connected to pm2');\n\n  ipm2.bus.on('*', function(event, data){\n    console.log(event, data.pm2_env.name);\n  });\n\n  setTimeout(function() {\n    ipm2.rpc.restartProcessId(0, function(err, dt) {\n      console.log(dt);\n    });\n  }, 2000);\n\n\n  ipm2.rpc.getMonitorData({}, function(err, dt) {\n    console.log(dt);\n  });\n});\n```\n\n## Example 2-way\n\nin your process script\n```javascript\nif (send in process) {\n  process.on(\"message\", function (msg) {\n    if ( \"type\" in msg && msg.type === \"god:heap\" ) {\n        var heap = process.memoryUsage().heapUsed\n      process.send({type:\"process:heap\", heap:heap})\n    }\n  })\n}\n\nvar myMemoryLeak = []\n\nsetInterval( function () {\n  var object = {}\n  for (var i = 0; i < 10000; i++) {\n    object[\"key\"+i] = Math.random().toString(36).substring(7)\n  }\n\n  myMemoryLeak.push(object)\n\n}, Math.round(Math.random()*2000))\n```\nin monitoring script\n```javascript\nvar ipm2 = require('pm2-interface')()\n\nipm2.on('ready', function() {\n\n    console.log('Connected to pm2')\n\n    ipm2.bus.on('process:heap', function(data){\n        console.log(\"process heap:\", data)\n    })\n\n\n    setInterval( function () {\n        var msg = {type:\"god:heap\"}   // god: is arbitrary and used to distinguish incoming & outgoing msgs\n        ipm2.rpc.msgProcess({name:\"worker\", msg:msg}, function (err, res) {\n            if (err) console.log(err)\n            else console.log(res)\n        })\n    }, 5000)\n})\n```\nStart pm2 and monitoring script + output:\n```shell\npm2 start worker.js -i 3 --name worker\nnode monitor.js\n\nsent 3 messages   # coming from the console.log(res)\nprocess heap: { pm_id: 0, msg: { type: 'process:heap', heap: 43416064 } }\nprocess heap: { pm_id: 1, msg: { type: 'process:heap', heap: 18373704 } }\nprocess heap: { pm_id: 2, msg: { type: 'process:heap', heap: 80734256 } }\nsent 3 messages\nprocess heap: { pm_id: 0, msg: { type: 'process:heap', heap: 61994096 } }\nprocess heap: { pm_id: 1, msg: { type: 'process:heap', heap: 22437400 } }\nprocess heap: { pm_id: 2, msg: { type: 'process:heap', heap: 116622432 } }\nsent 3 messages\nprocess heap: { pm_id: 0, msg: { type: 'process:heap', heap: 79641168 } }\nprocess heap: { pm_id: 1, msg: { type: 'process:heap', heap: 32260112 } }\nprocess heap: { pm_id: 2, msg: { type: 'process:heap', heap: 156047904 } }\n\npm2 delete all\n```\n\n## Disconnect\n\nSince pm2-interface interacts with PM2 via sockets, any script which uses pm2-interface will remain alive even when the node.js event loop is empty. `process.exit()` can be called to forcefully exit, or, if your script has finished making calls to PM2, you may call `ipm2.disconnect()` to disconnect the socket connections and allow node to exit automatically.\n\n```javascript\nipm2.on('ready', function() {\n\n  // ...\n\n  ipm2.disconnect();\n});\n```\n\n> Calling `disconnect()` means \"I am entirely done interacting with PM2.\" You will no longer be able to receive messages on `ipm2.bus` or send requests on `ipm2.rpc`. To reconnect you must completely start over with a new ipm2 object.\n\n## Ideas\n\n- Catching exceptions and fowarding them by mail\n- A web interface to control PM2\n\n## Apache v2 License\n","_attachments":{},"homepage":"https://github.com/Unitech/pm2-interface","bugs":{"url":"https://github.com/Unitech/pm2-interface/issues"},"license":"Apache v2"}