File tree 5 files changed +11
-7
lines changed
5 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -112,8 +112,11 @@ module.exports = {
112
112
port : 8080 ,
113
113
114
114
// number of workers' groups; each group will
115
- // have its own port number (port + group number)
116
- groups : 2
115
+ // have its own port number (port + group number * ports per group..port + (group number + 1) * ports per group - 1)
116
+ groups : 2 ,
117
+
118
+ // number of ports per worker group; default 1
119
+ portsPerGroup: 2 ,
117
120
},
118
121
119
122
// extensions to load
Original file line number Diff line number Diff line change 11
11
},
12
12
13
13
"server" : {
14
- "port" : 10080 ,
14
+ "port" : 8080 ,
15
15
"groups" : 3
16
16
}
17
17
}
Original file line number Diff line number Diff line change 1
1
const http = require ( 'http' ) ,
2
2
worker = require ( 'luster' ) ;
3
3
4
- if ( worker . wid === 1 || worker . wid === 0 ) {
5
- console . log ( 'try to open http://localhost:%s' , process . env . port ) ;
6
- }
4
+ console . log ( 'Worker #%s: try to open http://localhost:%s' , worker . wid , process . env . port ) ;
7
5
8
6
http
9
7
. createServer ( ( req , res ) => {
Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ const CHECKS = {
34
34
'server.port' : { type : [ 'number' , 'string' ] } ,
35
35
// increase port for every group
36
36
'server.groups' : { type : 'number' } ,
37
+ // number of ports for each group
38
+ 'server.portsPerGroup' : { type : 'number' } ,
37
39
// hash of extensions; keys – modules' names, values – extensions' configs
38
40
'extensions' : { type : 'object' } ,
39
41
// path to node_modules directory which contains extensions
Original file line number Diff line number Diff line change @@ -221,6 +221,7 @@ class Master extends ClusterProcess {
221
221
count = this . config . get ( 'workers' , os . cpus ( ) . length ) ,
222
222
isServerPortSet = this . config . has ( 'server.port' ) ,
223
223
groups = this . config . get ( 'server.groups' , 1 ) ,
224
+ portsPerGroup = this . config . get ( 'server.portsPerGroup' , 1 ) ,
224
225
workersPerGroup = Math . floor ( count / groups ) ;
225
226
226
227
let port ,
@@ -240,7 +241,7 @@ class Master extends ClusterProcess {
240
241
stopTimeout,
241
242
exitThreshold,
242
243
allowedSequentialDeaths,
243
- port : isServerPortSet ? port . next ( group ) : 0 ,
244
+ port : isServerPortSet ? port . next ( group * portsPerGroup ) : 0 ,
244
245
maxListeners : this . getMaxListeners ( ) ,
245
246
} ) ) ;
246
247
You can’t perform that action at this time.
0 commit comments