JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1899
  • Score
    100M100P100Q105375F

Process Manager for Node.js, branched from node-cluster.

Package Exports

  • pm

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 (pm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status

About

pm 是一个轻量级的Node.js多进程管理器,基于之前的node-cluster重构而来,在淘宝内部的生产系统中得到了广泛的应用.

  • 基于 master + worker 模式,master负责进程管理,worker 处理业务逻辑,有效利用现代服务器的多CPU;
  • 同一 master 可管理多种类型的worker, 并且支持在不同类型的 worker 之间进行轻量的消息传递;
  • 同一类型的 worker ,在 master 中进行负载均衡和健康检查,尤其对于类似死循环导致的“假死”情况有很好的识别;
  • 平滑退出和 不退出前提下的 worker 进程重载 (reload).

Install

$ npm install pm

Usage

  • in master.js, run as master:
var app = require('pm').createMaster({
 'pidfile' : '/tmp/demo.pid',
});

app.register('group1', __dirname + '/http.js', {
 'listen' : [8080, 8081]
});
  • in http.js, run as worker:
var http = require('http').createServer(function (req, res) {
 res.end('hello world');
});

require('pm').createWorker().ready(function (socket, port) {
 http.emit('connection', socket);
});
  • demo 目录下你能看到更多的示例代码.

Test

unit test

$ make test

jscoverage: 75%

$ make cov

Contributors

Thanks goes to the people who have contributed code to this module, see the GitHub Contributors page.

Below is the output from git-summary

 project: pm
 commits: 217
 files  : 23
 authors: 
   181	aleafs                  83.4%
    22	fengmk2                 10.1%
     6	Jackson Tian            2.8%
     6	aleafs zhang            2.8%
     1	Will Wen Gunn           0.5%
     1	pengchun                0.5%

License

pm is published under MIT license. See license text in LICENSE file.