Skip to content

Commit

Permalink
refactor: properly handle http server port in use error
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Nov 22, 2019
1 parent e2ca688 commit 263a503
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Ignitor/HttpServer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ export class HttpServer {

this._server.instance!.on('error', async (error: NodeJS.ErrnoException) => {
if (error.code === 'EADDRINUSE') {
this._server.instance!.close()
return
this._logger.trace(`Port in use, closing server`)
}

await this.kill(3000)
Expand Down Expand Up @@ -199,8 +198,8 @@ export class HttpServer {
this._setLogger()
this._setServer()
this.createServer(serverCallback)
await this.listen()
this._monitorHttpServer()
await this.listen()
this._signalsListener.listen(() => this.close())
} catch (error) {
new ErrorHandler(this.application).handleError(error)
Expand Down

0 comments on commit 263a503

Please sign in to comment.