aleafs / pm Goto Github PK
View Code? Open in Web Editor NEWA graceful node library to contribute a permanent "master-worker" server.
License: MIT License
A graceful node library to contribute a permanent "master-worker" server.
License: MIT License
春哥好,有个问题请教下,我现在想用pm配合kraken来使用,但是发现用起来有问题,集成的时候无法监听端口,请问有什么好办法么
send message to all workers named by given. Message will be sent by other worker process in most case.
sendto(name, message) {
}
Working on it.
master.register的参数按readme是不正确的啊,我只能是查源码才发现还是源码靠得住些
/**
80
, [80, 8080]
or [80, '/tmp/web.sock']
.os.cpu
number.0
, no limit.5
.false
.在高并发场景下,master以极低的概率异常退出,报错如下(0.6.11):
node: src/unix/stream.c:386: uv__write: Assertion `fd_to_send >= 0' failed.
并产生assert fail的core dump。
能否支持worker在不同的机器上跑?
I'm try to fixed all test cases, let them all pass.
http://nodejs.org/docs/v0.8.23/api/cluster.html#cluster_class_worker
Worker.disconnect()
原因是,在nodejs bindinds里面,tcp_wrap.cc文件的第140行有对实例化时传入的参数进行检验:
lib/common.js
里面,类比一下,
lib/common.js
中的pipe_wrap
应该也会有同样的问题
2019-10-10 17:02:22
windows系统下,当使用IPC命名管道时,lib/common.js
中第22
行:
应该为2, 在pipe_wrap.h
文件中可以看到
在lib/child.js
中,在windows环境下使用IPC命名管道时,可能会出现handle.setSimultaneousAccepts is not a function
的错误,这个错误的报错位置为internal/child_process.js
, 可以看出如下发送的句柄出现问题
只接用 http模块可以用 emit 函数
如果是 express 怎么要来用
/**
* 注册一类worker进程
*
* @param {String} name
* @param {String} script file
* @param {Object} options
* @param {Array} args
* @return {Object} workerPair
*/
register(name, file, options, args) {
}
index.js 中的导致方法命名规范不正确
exports.Master = function (options) {
return master.create(options);
};
exports.Worker = function (options) {
return worker.create(options);
};
既然 Master
和 Worker
是两个方法,那么应该命名 master
和 worker
.
Reload all workers by worker name
reload(name) {
}
因为 express 2.x 中的 app.error 是用于在 app.on('listening',... 的时候才将错误处理加到 app middleware stack 里面确保错误处理在middleware的最后。
请在 readme 里面提醒用户注意此事,在 worker.ready()
前加上
app.emit('listening')
你好,有个关于产品上线之后后,代码更新的问题请教你!
我们打算使用pm 和 nginx 的upstream来部署程序
使用pm开启两个master 进程,nginx做负载
更新线上代码时,我希望kill掉一个进程后,原来已经连接的请求还能继续处理并返回,
请问在pm下有什么好的办法解决这个问题吗?
谢谢~(●ˇ∀ˇ●)
aaaaa
[master:7555][Fri Aug 03 2012 09:05:44 GMT+0800 (CST)] new worker forked (7562) as "/home/pengchun/work/iservice/app/rest.js"
[master:7555][Fri Aug 03 2012 09:05:45 GMT+0800 (CST)] Got SIGTERM, about to exit...
[master:7555][Fri Aug 03 2012 09:05:45 GMT+0800 (CST)] SIGTERM exited
/home/pengchun/work/iservice/node_modules/pm/lib/master.js:200
pstat[i] = msg.data[i];
^
TypeError: Cannot set property 'status' of undefined
at ChildProcess. (/home/pengchun/work/iservice/node_modules/pm/lib/master.js:200:22)
at ChildProcess.emit (events.js:70:17)
at Pipe.onread (child_process.js:102:16)
[worker:7562][Fri Aug 03 2012 09:05:46 GMT+0800 (CST)] terminated after 2.064 seconds.
以下代码:
// 文件:master.js
var pm = require('pm');
var master = pm.createMaster();
master.register('test', 'worker.js', {
listen: 8080,
children: 2
});
// 文件:worker.js
var http = require('http').createServer(function (req, res) {
worker.reload();
res.write('hello world');
setTimeout(function () {
res.end('end');
}, 6000);
});
var worker = require('pm').createWorker().ready(function (socket, port) {
http.emit('connection', socket);
});
用浏览器发出一个请求之后,worker.js就执行了reload()
,但是要在6秒后才会运行res.end()
结束该次请求,我希望在执行worker.reload()
后,会启动新的worker进程来接收新的请求,但是当前的worker进程要等待处理完所有请求(或者超时后)才退出,上面的代码貌似不能实现这个需求。
PM监听端口有没有个数限制?[8080,8081,8082,8083]是否可以?
[master:15324][Fri Aug 10 2012 19:21:36 GMT+0800 (CST)] new worker forked (28497) as "***/app/rest/index.js"
[master:15324][Fri Aug 10 2012 19:21:36 GMT+0800 (CST)] [28497] maybe already been dead, killing ...
如果传递接口,默认是监听某个端口,如果一台机器有多个IP,想指定监听特定的IP的时候是不是不行?能够有个参数传递监听的IP,一些内部应用不想直接bind(0.0.0.0).
/Users/dongming/dev/github/fdserver/node_modules/pm/lib/child.js:271
handles[i].close();
^
TypeError: Cannot call method 'close' of null
at /Users/dongming/dev/github/fdserver/node_modules/pm/lib/child.js:271:18
at Array.forEach (native)
at Child.stop (/Users/dongming/dev/github/fdserver/node_modules/pm/lib/child.js:270:26)
at /Users/dongming/dev/github/fdserver/node_modules/pm/lib/master.js:172:19
at Array.forEach (native)
at Master.shutdown (/Users/dongming/dev/github/fdserver/node_modules/pm/lib/master.js:171:27)
at process.<anonymous> (/Users/dongming/dev/github/fdserver/node_modules/pm/lib/master.js:99:13)
at process.EventEmitter.emit (events.js:98:17)
at process.<anonymous> (/Users/dongming/dev/github/fdserver/node_modules/pm/lib/master.js:106:15)
at process.EventEmitter.emit (events.js:92:17)
在win平台下demo没有跑起来
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.