e287d5039fb76d68eda80ba7e9ebb0de7cef6da4
7 var app
= require('../app');
8 var debug
= require('debug')('vc:server');
9 var http
= require('http');
12 * Get port from environment and store in Express.
15 var port
= normalizePort(process
.env
.PORT
|| '3000');
16 app
.set('port', port
);
22 var server
= http
.createServer(app
);
25 * Listen on provided port, on all network interfaces.
29 server
.on('error', onError
);
30 server
.on('listening', onListening
);
36 const WebSocket
= require('ws');
37 const wss
= new WebSocket
.Server({ server: server
});
38 require('../sockets')(wss
);
41 * Normalize a port into a number, string, or false.
44 function normalizePort(val
) {
45 var port
= parseInt(val
, 10);
61 * Event listener for HTTP server "error" event.
64 function onError(error
) {
65 if (error
.syscall
!== 'listen') {
69 var bind
= typeof port
=== 'string'
73 // handle specific listen errors with friendly messages
76 console
.error(bind
+ ' requires elevated privileges');
80 console
.error(bind
+ ' is already in use');
89 * Event listener for HTTP server "listening" event.
92 function onListening() {
93 var addr
= server
.address();
94 var bind
= typeof addr
=== 'string'
96 : 'port ' + addr
.port
;
97 debug('Listening on ' + bind
);