Skip to content

Commit

Permalink
Port in use error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilM98 committed Dec 11, 2018
1 parent fee5451 commit 44e6407
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/index.ts
Expand Up @@ -105,17 +105,26 @@ export class Probot {
}

public start () {
if (this.options.webhookProxy) {
createWebhookProxy({
logger,
path: this.options.webhookPath,
port: this.options.port,
url: this.options.webhookProxy
})
}
this.server.listen(this.options.port, () => {
if (this.options.webhookProxy) {
createWebhookProxy({
logger,
path: this.options.webhookPath,
port: this.options.port,
url: this.options.webhookProxy
})
}

this.server.listen(this.options.port)
logger.info('Listening on http://localhost:' + this.options.port)
logger.info('Listening on http://localhost:' + this.options.port)
}).on('error', (err: NodeJS.ErrnoException) => {
if(err.code === 'EADDRINUSE'){
logger.error(`Port:${this.options.port} is already in use. You can define the PORT environment variable to use a different port.`)
}
else {
logger.error(err)
}
process.exit()
})
}
}

Expand Down

0 comments on commit 44e6407

Please sign in to comment.