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: about 23 hours 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: 2024-10-05T22:04:48.219Z (about 1 month 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
[![NPM version](https://img.shields.io/npm/v/@zcong/node-worker-manager.svg?style=flat)](https://npmjs.com/package/@zcong/node-worker-manager) [![NPM downloads](https://img.shields.io/npm/dm/@zcong/node-worker-manager.svg?style=flat)](https://npmjs.com/package/@zcong/node-worker-manager) [![CircleCI](https://circleci.com/gh/zcong1993/node-worker-manager/tree/master.svg?style=shield)](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)