fix(web): change port to 3007, add auto port cleanup, graceful error handling
This commit is contained in:
@@ -25,8 +25,20 @@ app.use('/api/configs', configsRouter);
|
||||
|
||||
wss.on('connection', handleChat);
|
||||
|
||||
const PORT = 3001;
|
||||
const PORT = 3007;
|
||||
initDb();
|
||||
|
||||
server.on('error', (err: NodeJS.ErrnoException) => {
|
||||
if (err.code === 'EADDRINUSE') {
|
||||
console.error(`Port ${PORT} is in use. Run: npx kill-port ${PORT}`);
|
||||
process.exit(1);
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
|
||||
server.listen(PORT, () => {
|
||||
console.log(`Server running on http://localhost:${PORT}`);
|
||||
});
|
||||
|
||||
process.on('SIGTERM', () => { server.close(); process.exit(0); });
|
||||
process.on('SIGINT', () => { server.close(); process.exit(0); });
|
||||
|
||||
Reference in New Issue
Block a user