#510 Detect when the port you are trying to run the server on is already in use.
This commit is contained in:
11
src/index.js
11
src/index.js
@@ -188,6 +188,17 @@ function ParseServer({
|
|||||||
|
|
||||||
api.use(middlewares.handleParseErrors);
|
api.use(middlewares.handleParseErrors);
|
||||||
|
|
||||||
|
|
||||||
|
process.on('uncaughtException', (err) => {
|
||||||
|
if( err.code === "EADDRINUSE" ) { // user-friendly message for this common error
|
||||||
|
console.log(`Unable to listen on port ${err.port}. The port is already in use.`);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return api;
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user