()
| 41 | } |
| 42 | |
| 43 | setupHttpServer() { |
| 44 | if (this.startOptions.ssl) { |
| 45 | this.httpServer = this.createHttpsServer(); |
| 46 | } else { |
| 47 | this.httpServer = this.http.createServer(this.app); |
| 48 | } |
| 49 | |
| 50 | // We have to keep track of sockets so that we can close them |
| 51 | // when we need to restart. |
| 52 | this.sockets = {}; |
| 53 | this.nextSocketId = 0; |
| 54 | this.httpServer.on('connection', (socket) => { |
| 55 | let socketId = this.nextSocketId++; |
| 56 | this.sockets[socketId] = socket; |
| 57 | |
| 58 | socket.on('close', () => { |
| 59 | delete this.sockets[socketId]; |
| 60 | }); |
| 61 | }); |
| 62 | } |
| 63 | |
| 64 | createHttpsServer() { |
| 65 | if (!fs.existsSync(this.startOptions.sslKey)) { |
no test coverage detected