{"name":"cfork","version":"1.2.3","description":"cluster fork and restart easy way","main":"index.js","scripts":{"test":"mocha --check-leaks -R spec -t 10000 test/*.test.js","jshint":"jshint .","autod":"autod -w --prefix '~'","cnpm":"npm install --registry=https://registry.npm.taobao.org","contributors":"contributors -f plain -o AUTHORS"},"dependencies":{},"devDependencies":{"autod":"*","contributors":"*","graceful":"~0.1.0","jshint":"*","mocha":"*","pedding":"~1.0.0","should":"~4.0.4","urllib":"~2.0.2"},"homepage":"https://github.com/node-modules/cfork","repository":{"type":"git","url":"git://github.com/node-modules/cfork.git","web":"https://github.com/node-modules/cfork"},"bugs":{"url":"https://github.com/node-modules/cfork/issues","email":"fengmk2@gmail.com"},"keywords":["cluster","cluster-fork","cfork","restart"],"engines":{"node":">= 0.10.0"},"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","contributors":[{"name":"fengmk2","email":"fengmk2@gmail.com","url":"https://github.com/fengmk2"},{"name":"JacksonTian","email":"shyvo1987@gmail.com","url":"https://github.com/JacksonTian"},{"name":"dead-horse","email":"heyiyu.deadhorse@gmail.com","url":"https://github.com/dead-horse"},{"name":"coderhaoxin","email":"coderhaoxin@outlook.com","url":"https://github.com/coderhaoxin"}],"gitHead":"b84316eca10a997514b00addfd3cb734154fe791","_id":"cfork@1.2.3","_shasum":"c5e24dc0eb0b17fad2db3d8507cb9c06478808f9","_from":".","_npmVersion":"2.9.0","_nodeVersion":"2.0.0","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"dist":{"shasum":"c5e24dc0eb0b17fad2db3d8507cb9c06478808f9","tarball":"http://registry-npm.ywwl.com/cfork/download/cfork-1.2.3.tgz","integrity":"sha512-hTAZI4u1rT8f0cfeNtP5Q75IpG2yrdDycEnSes1HLSfFpcLf0lX9ni3APs39sN4BUF63c9SGLGY7gh9pDFg9vA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA+/VBhCo4pFL5DoHKBWUY18BhsQM/LoXMh2IM6ibD2CAiB4dWuwuA/i/659jVfGbIhAoXIJXaPfOzADyVzq6aIT1w=="}],"size":3904,"noattachment":false,"key":"/cfork/-/cfork-1.2.3.tgz"},"directories":{},"readme":"cfork\n=======\n\n[![NPM version][npm-image]][npm-url]\n[![Node.js CI](https://github.com/node-modules/cfork/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/cfork/actions/workflows/nodejs.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/cfork.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/cfork\n[codecov-image]: https://codecov.io/gh/node-modules/cfork/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/node-modules/cfork\n[download-image]: https://img.shields.io/npm/dm/cfork.svg?style=flat-square\n[download-url]: https://npmjs.org/package/cfork\n\ncluster fork and restart easy way.\n\n* Easy fork with worker file path\n* Handle worker restart, even it was exit unexpected.\n* Auto error log process `uncaughtException` event\n\n## Install\n\n```bash\n$ npm install cfork --save\n```\n\n## Usage\n\n### Example\n\n```js\nconst cfork = require('cfork');\nconst util = require('util');\n\nconst clusterWorker = cfork({\n  exec: '/your/app/worker.js',\n  // slaves: ['/your/app/slave.js'],\n  // count: require('os').cpus().length,\n}).on('fork', worker => {\n    console.warn('[%s] [worker:%d] new worker start', Date(), worker.process.pid);\n  })\n  .on('disconnect', worker => {\n    console.warn('[%s] [master:%s] wroker:%s disconnect, exitedAfterDisconnect: %s, state: %s.',\n      Date(), process.pid, worker.process.pid, worker.exitedAfterDisconnect, worker.state);\n  })\n  .on('exit', (worker, code, signal) => {\n    const exitCode = worker.process.exitCode;\n    const err = new Error(util.format('worker %s died (code: %s, signal: %s, exitedAfterDisconnect: %s, state: %s)',\n      worker.process.pid, exitCode, signal, worker.exitedAfterDisconnect, worker.state));\n    err.name = 'WorkerDiedError';\n    console.error('[%s] [master:%s] wroker exit: %s', Date(), process.pid, err.stack);\n  })\n  // if you do not listen to this event\n  // cfork will output this message to stderr\n  .on('unexpectedExit', (worker, code, signal) => {\n    // logger what you want\n  })\n  // emit when reach refork times limit\n  .on('reachReforkLimit', () => {\n    // do what you want\n  });\n\n// if you do not listen to this event\n// cfork will listen it and output the error message to stderr\nprocess.on('uncaughtException', err => {\n  // do what you want\n});\n\n// if you want to dynamically disable refork, you can call the setDisableRefork, priority over the refork parameter\ncfork.setDisableRefork(clusterWorker, true);\n\n\n```\n\n### Options\n\n- **exec** : exec file path\n- **slaves** : slave process config\n- **args** : exec arguments\n- **count** : fork worker nums, default is `os.cpus().length`\n- **refork** : refork when worker disconnect or unexpected exit, default is `true`\n- **limit**: limit refork times within the `duration`, default is `60`\n- **duration**: default is `60000`, one minute (so, the `refork times` < `limit / duration`)\n- **autoCoverage**: auto fork with istanbul when `running_under_istanbul` env set, default is `false`\n- **env**: attach some environment variable key-value pairs to the worker / slave process, default to an empty object.\n- **windowsHide**: Hide the forked processes console window that would normally be created on Windows systems, default to false.\n- **serialization**: Specify the kind of serialization used for sending messages between processes. Possible values are 'json' and 'advanced'. See Advanced serialization for child_process for more details. Default: false.\n\n## License\n\n[MIT](LICENSE)\n\n<!-- GITCONTRIBUTOR_START -->\n\n## Contributors\n\n|[<img src=\"https://avatars.githubusercontent.com/u/156269?v=4\" width=\"100px;\"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/14790466?v=4\" width=\"100px;\"/><br/><sub><b>greenkeeperio-bot</b></sub>](https://github.com/greenkeeperio-bot)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/985607?v=4\" width=\"100px;\"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/327019?v=4\" width=\"100px;\"/><br/><sub><b>JacksonTian</b></sub>](https://github.com/JacksonTian)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/1474688?v=4\" width=\"100px;\"/><br/><sub><b>luckydrq</b></sub>](https://github.com/luckydrq)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/2842176?v=4\" width=\"100px;\"/><br/><sub><b>XadillaX</b></sub>](https://github.com/XadillaX)<br/>|\n| :---: | :---: | :---: | :---: | :---: | :---: |\n|[<img src=\"https://avatars.githubusercontent.com/u/360661?v=4\" width=\"100px;\"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/18315?v=4\" width=\"100px;\"/><br/><sub><b>hemanth</b></sub>](https://github.com/hemanth)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/3230673?v=4\" width=\"100px;\"/><br/><sub><b>qingdengyue</b></sub>](https://github.com/qingdengyue)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/1422472?v=4\" width=\"100px;\"/><br/><sub><b>jpuncle</b></sub>](https://github.com/jpuncle)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/1102038?v=4\" width=\"100px;\"/><br/><sub><b>hustxiaoc</b></sub>](https://github.com/hustxiaoc)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/2972143?v=4\" width=\"100px;\"/><br/><sub><b>nightink</b></sub>](https://github.com/nightink)<br/>|\n[<img src=\"https://avatars.githubusercontent.com/u/7971415?v=4\" width=\"100px;\"/><br/><sub><b>paranoidjk</b></sub>](https://github.com/paranoidjk)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/19849579?v=4\" width=\"100px;\"/><br/><sub><b>sinkhaha</b></sub>](https://github.com/sinkhaha)<br/>\n\nThis project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sat May 06 2023 00:30:47 GMT+0800`.\n\n<!-- GITCONTRIBUTOR_END -->\n","publish_time":1431102412313,"_cnpm_publish_time":1431102412313,"dist-tags":{"latest":"2.0.0"}}