http.createServer(app).listen(app.get('port'), function () { console.log('Express server listening on port ' + app.get('port')); });
constructor(conf: ChatWorkerConf) { this._debug = debugFactory('ChatUp:ChatWorker:slave:' + process.pid); this._debug('Slave init'); this._conf = conf; if (conf.ssl && conf.ssl.key && conf.ssl.cert) { this._app = https.createServer(conf.ssl); } else { this._app = http.createServer(); } this._io = socketio(this._app, { serverClient: false }); this._store = new Store(this._conf); this._io.on('connection', this._onConnection); this._sockets = []; this._initStatsReporting(); }
/** * Shorthand for: * * http.createServer(app.callback()).listen(...) * * @param {Mixed} ... * @return {Server} * @api public */ listen(...args: any[]): object { debug('listen'); const server = http.createServer(this.callback()); return server.listen(...args); }
const createPeerServer = async () => { const corsOptions = { origin: function (origin, callback) { if (!origin) { throw new Error('Origin undefined') } const ALLOW_ORIGINS = process.env.SOCKET_IO_ALLOW_ORIGINS; const originNormalized = origin.split(':').length === 2? `${origin}:80`: origin; const hasOrigin = ALLOW_ORIGINS.split(',').indexOf(originNormalized) !== -1; hasOrigin || ALLOW_ORIGINS === '*:*' ? callback(null, true) : callback(new Error('Not allowed by CORS')); } }; const expressAPP = express(); const server = http.createServer(expressAPP); expressAPP.use(cors(corsOptions)); const peerServer = ExpressPeerServer(server) expressAPP.use(peerServer); server.listen(process.env.PEER_SERVER_PORT, () => { Logger.log(`Server Peer running on http://localhost:${process.env.PEER_SERVER_PORT}`, 'Bootstrap'); }) peerServer.on('connection', (client) => { console.log(`[X] Client connected on peer server: ${client}`); }); }
http.createServer(app).listen(app.get('port'), function () { console.log('Express server listening on port ' + app.get('port')); });
http.createServer(app).listen(app.get('port'), function () { console.log('Express server listening on port ' + app.get('port')); });
http.createServer(app).listen(app.get('port'), function () { console.log('Express server listening on port ' + app.get('port')); });