Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add feature: support child process debug mode #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions master.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,31 @@ function main(fn){

var childs = [];
function startWorker(handle){
for(var i=0; i<WORKER_NUMBER; i++){
var c = cp.fork(WORKER_PATH);
c.send({"server" : true}, handle);
childs.push(c);
}
/*
setInterval(function(){
inspect(childMng.getStatus());
childMng.updateStatus();
},WORKER_HEART_BEAT);
*/
var debug = isDebug();
for(var i=0; i<WORKER_NUMBER; i++){
var c = null;
if (debug){
c = cp.fork(WORKER_PATH,{execArgv: [ '--debug='+(process.debugPort+i+1) ]});
}else{
c = cp.fork(WORKER_PATH);
}
c.send({"server" : true}, handle);
childs.push(c);
}
/*
setInterval(function(){
inspect(childMng.getStatus());
childMng.updateStatus();
},WORKER_HEART_BEAT);
*/
function isDebug(){
for(var i=0;i<process.execArgv.length;i++){
if(process.execArgv[i].indexOf("--debug")==0 ){
return true;
}
}
return false;
}
}

var exitTimer = null;
Expand Down
23 changes: 19 additions & 4 deletions tcpMaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,31 @@ function output(str){
var childs = [];
var lastChildPos = 0;
function startWorker(){
for(var i=0; i<WORKER_NUMBER; i++){
var c = cp.fork(WORKER_PATH);
childs.push(c);
}
var debug = isDebug();
for(var i=0; i<WORKER_NUMBER; i++){
var c = null;
if (debug){
c = cp.fork(WORKER_PATH,{execArgv: [ '--debug='+(process.debugPort+i+1) ]});
}else{
c = cp.fork(WORKER_PATH);
}
childs.push(c);
}
function isDebug(){
for(var i=0;i<process.execArgv.length;i++){
if(process.execArgv[i].indexOf("--debug")==0 ){
return true;
}
}
return false;
}
/*
setInterval(function(){
inspect(childMng.getStatus());
childMng.updateStatus();
},WORKER_HEART_BEAT);
*/

}

var server = null;
Expand Down