Skip to content

Commit d400d32

Browse files
authored
Merge pull request #553 from witheve/corey
Better messages for Eve server
2 parents a499a2d + 89510cc commit d400d32

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/runtime/server.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const contentTypes = {
3232
}
3333

3434
const BROWSER = !argv["server"];
35-
const PORT = process.env.PORT || 8080;
35+
const PORT = process.env.PORT || argv["port"] || 8080;
3636
const serverDatabase = new ServerDatabase();
3737
const shared = new PersistedDatabase();
3838

@@ -163,5 +163,13 @@ let wss = new WebSocketServer({server: server});
163163
initWebsocket(wss);
164164

165165
server.listen(PORT, function(){
166-
console.log("Server listening on: http://localhost:%s", PORT);
166+
console.log(`Eve is available at http://localhost:${PORT}. Point your browser there to access the Eve editor.`);
167+
});
168+
169+
// If the port is already in use, display an error message
170+
process.on('uncaughtException', function(err) {
171+
if(err.errno === 'EADDRINUSE') {
172+
console.log(`ERROR: Eve couldn't start because port ${PORT} is already in use.\n\nYou can select a different port for Eve using the "port" argument.\nFor example:\n\n> npm start -- --port 1234`);
173+
}
174+
process.exit(1);
167175
});

0 commit comments

Comments
 (0)