Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zcong1993/node-worker-manager
simple node worker manager
https://github.com/zcong1993/node-worker-manager
Last synced: 2 days ago
JSON representation
simple node worker manager
- Host: GitHub
- URL: https://github.com/zcong1993/node-worker-manager
- Owner: zcong1993
- License: mit
- Created: 2018-06-22T06:40:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-25T02:29:11.000Z (over 6 years ago)
- Last Synced: 2025-02-18T05:48:26.236Z (2 days ago)
- Language: JavaScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-worker-manager
[](https://npmjs.com/package/@zcong/node-worker-manager) [](https://npmjs.com/package/@zcong/node-worker-manager) [](https://circleci.com/gh/zcong1993/node-worker-manager/tree/master)
## Install
```bash
$ yarn add @zcong/node-worker-manager
```## Usage
> quickly start with `yarn example` or `yarn example:debug`
```js
// worker.js
const { parentPort } = require('worker_threads')parentPort.on('message', msg => {
// do something
console.log(msg)
})
``````js
// main thread
const path = require('path')
const WorkerManager = require('@zcong/node-worker-manager')const wm = new WorkerManager({
workerPath: path.resolve(__dirname, './worker.js'),
recreate: true,
nums: 2
})setInterval(() => {
wm.dispatch('test worker')
}, 1000)
```then run with command `node --experimental-worker index.js`
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D## Author
**node-worker-manager** © [zcong1993](https://github.com/zcong1993), Released under the [MIT](./LICENSE) License.
Authored and maintained by zcong1993 with help from contributors ([list](https://github.com/zcong1993/node-worker-manager/contributors)).> [github.com/zcong1993](https://github.com/zcong1993) · GitHub [@zcong1993](https://github.com/zcong1993)