Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Port in use error handling (#767) #784

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/index.ts
Expand Up @@ -105,17 +105,25 @@ 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(1)
})
}
}

Expand Down