@@ -158,6 +158,17 @@ exports.http = function(count, mode, options, callback) {
158
158
fork ( ) ;
159
159
} ;
160
160
161
+ exports . https = function ( count , mode , options , callback ) {
162
+ // Fork will obtain options automatically via event
163
+ if ( Cluster . isMaster ) {
164
+ CLUSTER_REQ . id = 'master' ;
165
+ CLUSTER_RES . id = 'master' ;
166
+ CLUSTER_EMIT . id = 'master' ;
167
+ master ( count , mode , options , callback , true ) ;
168
+ } else
169
+ fork ( ) ;
170
+ } ;
171
+
161
172
exports . restart = function ( index ) {
162
173
if ( index === undefined ) {
163
174
for ( var i = 0 ; i < THREADS ; i ++ )
@@ -173,7 +184,7 @@ exports.restart = function(index) {
173
184
}
174
185
} ;
175
186
176
- function master ( count , mode , options , callback ) {
187
+ function master ( count , mode , options , callback , https ) {
177
188
178
189
if ( count == null || count === 'auto' )
179
190
count = require ( 'os' ) . cpus ( ) . length ;
@@ -222,7 +233,7 @@ function master(count, mode, options, callback) {
222
233
} ;
223
234
224
235
count . async ( function ( i , next ) {
225
- exec ( Math . abs ( i - THREADS ) ) ;
236
+ exec ( Math . abs ( i - THREADS ) , https ) ;
226
237
can ( next ) ;
227
238
} , function ( ) {
228
239
callback && callback ( FORKS ) ;
@@ -258,7 +269,7 @@ function mastersend(m) {
258
269
FORKS [ i ] && FORKS [ i ] . send ( m ) ;
259
270
}
260
271
261
- function exec ( index ) {
272
+ function exec ( index , https ) {
262
273
var fork = Cluster . fork ( ) ;
263
274
fork . $id = index . toString ( ) ;
264
275
fork . on ( 'message' , message ) ;
@@ -272,7 +283,7 @@ function exec(index) {
272
283
( function ( fork ) {
273
284
setTimeout ( function ( ) {
274
285
OPTIONS . options . id = fork . $id ;
275
- fork . send ( { TYPE : 'init' , bundling : ! CONTINUE , id : fork . $id , mode : OPTIONS . mode , options : OPTIONS . options , threads : OPTIONS . count , index : index } ) ;
286
+ fork . send ( { TYPE : 'init' , bundling : ! CONTINUE , id : fork . $id , mode : OPTIONS . mode , options : OPTIONS . options , threads : OPTIONS . count , index : index , https : https } ) ;
276
287
} , fork . $id * 500 ) ;
277
288
} ) ( fork ) ;
278
289
}
@@ -290,7 +301,10 @@ function on_init(msg) {
290
301
CLUSTER_RES . id = msg . id ;
291
302
THREADS = msg . threads ;
292
303
msg . options . bundling = msg . bundling ;
293
- F . http ( msg . mode , msg . options ) ;
304
+ if ( msg . https )
305
+ F . https ( msg . mode , msg . options ) ;
306
+ else
307
+ F . http ( msg . mode , msg . options ) ;
294
308
F . isCluster = true ;
295
309
F . removeListener ( msg . TYPE , on_init ) ;
296
310
break ;
0 commit comments