@ -9,6 +9,7 @@ const log = require('npmlog');
const url = require ( 'url' ) ;
const url = require ( 'url' ) ;
const WebSocket = require ( 'uws' ) ;
const WebSocket = require ( 'uws' ) ;
const uuid = require ( 'uuid' ) ;
const uuid = require ( 'uuid' ) ;
const fs = require ( 'fs' ) ;
const env = process . env . NODE _ENV || 'development' ;
const env = process . env . NODE _ENV || 'development' ;
@ -70,6 +71,9 @@ const redisUrlToClient = (defaultConfig, redisUrl) => {
const numWorkers = + process . env . STREAMING _CLUSTER _NUM || ( env === 'development' ? 1 : Math . max ( os . cpus ( ) . length - 1 , 1 ) ) ;
const numWorkers = + process . env . STREAMING _CLUSTER _NUM || ( env === 'development' ? 1 : Math . max ( os . cpus ( ) . length - 1 , 1 ) ) ;
const startMaster = ( ) => {
const startMaster = ( ) => {
if ( ! process . env . SOCKET && process . env . PORT && isNaN ( + process . env . PORT ) ) {
log . warn ( 'UNIX domain socket is now supported by using SOCKET. Please migrate from PORT hack.' ) ;
}
log . info ( ` Starting streaming API server master with ${ numWorkers } workers ` ) ;
log . info ( ` Starting streaming API server master with ${ numWorkers } workers ` ) ;
} ;
} ;
@ -574,9 +578,16 @@ const startWorker = (workerId) => {
} ) ;
} ) ;
} , 30000 ) ;
} , 30000 ) ;
server . listen ( process . env . PORT || 4000 , process . env . BIND || '0.0.0.0' , ( ) => {
if ( process . env . SOCKET || process . env . PORT && isNaN ( + process . env . PORT ) ) {
server . listen ( process . env . SOCKET || process . env . PORT , ( ) => {
fs . chmodSync ( server . address ( ) , 0o666 ) ;
log . info ( ` Worker ${ workerId } now listening on ${ server . address ( ) } ` ) ;
} ) ;
} else {
server . listen ( + process . env . PORT || 4000 , process . env . BIND || '0.0.0.0' , ( ) => {
log . info ( ` Worker ${ workerId } now listening on ${ server . address ( ) . address } : ${ server . address ( ) . port } ` ) ;
log . info ( ` Worker ${ workerId } now listening on ${ server . address ( ) . address } : ${ server . address ( ) . port } ` ) ;
} ) ;
} ) ;
}
const onExit = ( ) => {
const onExit = ( ) => {
log . info ( ` Worker ${ workerId } exiting, bye bye ` ) ;
log . info ( ` Worker ${ workerId } exiting, bye bye ` ) ;