Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andycall/advance-child-pool
Advance Node.js child process pool, support multitype child process, error handing
https://github.com/andycall/advance-child-pool
Last synced: 6 days ago
JSON representation
Advance Node.js child process pool, support multitype child process, error handing
- Host: GitHub
- URL: https://github.com/andycall/advance-child-pool
- Owner: andycall
- Created: 2017-03-22T12:19:34.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-22T12:29:09.000Z (almost 8 years ago)
- Last Synced: 2024-10-19T04:30:34.532Z (2 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# advance-child-pool
Advance Node.js child process pool, support multitype child process, error handingsupport features:
+ child process pool manage
+ recover dead child process
+ message queue
+ muilti task config## Setup
### Config Master Process
```javascript
let childProcess = require('child-process-manager').childManager;const textFilePath = path.join(__dirname, 'text.js');
const fileFilePath = path.join(__dirname, 'file.js');
const errorFilePath = path.join(__dirname, 'error.js');// register child process
childProcess.registerTask('text', textFilePath);
childProcess.registerTask('file', fileFilePath);
childProcess.registerTask('error', errorFilePath);// start pool
childProcess.childStartUp();// send data to child
childProcess.sendData('text', {
data: 'helloworld'
}).then((res) => {
// response from child_process
console.log(res);
}).catch(err => {
// error from child_process
console.log(err);
});
```### Config Child
```javascript
let childTemplate = require('child-process-manager').childWorker;childTemplate((data, done) => {
done({
type: 'file',
msg: data.msg,
index: data.index
})
});
```## Test
run test
```javascript
npm test
```