JSPM

advance-child-pool

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q21410F
  • License MIT

Advance Node.js child process pool, support multitype child process, error handing

Package Exports

  • advance-child-pool

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (advance-child-pool) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

child-process-manager

全功能Node.js子进程管理器

支持以下强大的功能:

  • 进程池管理
  • 死进程复活
  • 消息队列
  • 多任务配置

Setup

主进程配置

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');

// 注册任务
childProcess.registerTask('text', textFilePath);
childProcess.registerTask('file', fileFilePath);
childProcess.registerTask('error', errorFilePath);

// 启动子进程
childProcess.childStartUp();

childProcess.sendData('text', {
    data: 'helloworld'
}).then((res) => {
    // response from child_process
    console.log(res);
}).catch(err => {
    // error from child_process
    console.log(err);
});

子进程配置

let childTemplate = require('child-process-manager').childWorker;

childTemplate((data, done) => {
    done({
        type: 'file',
        msg: data.msg,
        index: data.index
    })
});