Skip to content

Commit

Permalink
Merge pull request #2285 from adaptlearning/issue/2174
Browse files Browse the repository at this point in the history
Handle error when server already running
  • Loading branch information
taylortom authored Apr 2, 2019
2 parents c092cde + 09444ad commit e1aad32
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ Origin.prototype.startServer = function (options) {
app.server = server;
// Create a http server
var httpServer = require('http').createServer(server);
httpServer.on('error', error => {
if (error.code !== 'EADDRINUSE') return;
logger.log('error', `Port ${error.port} already in use. Please stop the server before continuing.`);
process.exit();
});
app._httpServer = httpServer.listen(port, function() {
// set up routes
app.router = router(app);
Expand Down

0 comments on commit e1aad32

Please sign in to comment.