Skip to content

Commit

Permalink
Better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Vuzi committed Jul 2, 2021
1 parent 1d0f53f commit 2cf012e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ export class StaticServer extends TypedEmitter<ServerEvents> {
this.server = http.createServer((req, res) => this.handleRequest(req, res))
this.terminator = createHttpTerminator({ server: this.server })

this.server.on('error', e => {
this.emit('failure', e)
this.stop()
})

this.server.listen(this.port, this.host, () => {
this.emit('start', this.host, this.port, this.source)
})
Expand Down

0 comments on commit 2cf012e

Please sign in to comment.