From 652384708e95dd0366209fe4f46dbfea9288525c Mon Sep 17 00:00:00 2001 From: Benoit Date: Thu, 21 May 2026 15:21:21 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20am=C3=A9lioration=20gestion=20erreur=20p?= =?UTF-8?q?ort=20d=C3=A9j=C3=A0=20utilis=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Support variable PORT en environnement - Gestion propre de l'erreur EADDRINUSE - Message d'aide pour utiliser un port alternatif đŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- server/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/server/index.js b/server/index.js index ce61d7e..94b5ef4 100644 --- a/server/index.js +++ b/server/index.js @@ -20,7 +20,7 @@ const LIVEKIT_API_KEY = process.env.LIVEKIT_API_KEY || 'devkey'; const LIVEKIT_API_SECRET = process.env.LIVEKIT_API_SECRET || 'secret'; const LIVEKIT_URL = process.env.LIVEKIT_URL || config.server.livekit.url; const USE_LOCAL_LIVEKIT = process.env.USE_LOCAL_LIVEKIT === 'true'; -const SERVER_PORT = config.server.port; +const SERVER_PORT = parseInt(process.env.PORT || config.server.port, 10); const SERVER_HOST = config.server.host; // Logging @@ -261,13 +261,24 @@ async function start() { } // 2. DĂ©marrer API REST - app.listen(SERVER_PORT, SERVER_HOST, () => { + const server = app.listen(SERVER_PORT, SERVER_HOST, () => { log('info', `✓ API REST dĂ©marrĂ©e sur http://${SERVER_HOST}:${SERVER_PORT}`); log('info', ''); log('info', 'Serveur prĂȘt !'); log('info', `Groupes configurĂ©s: ${config.groups.map(g => g.name).join(', ')}`); }); + // GĂ©rer erreur port dĂ©jĂ  utilisĂ© + server.on('error', (error) => { + if (error.code === 'EADDRINUSE') { + log('error', `❌ Port ${SERVER_PORT} dĂ©jĂ  utilisĂ©`); + log('info', `💡 Essayez avec: PORT=3001 npm run dev`); + process.exit(1); + } else { + throw error; + } + }); + } catch (error) { log('error', 'Erreur dĂ©marrage:', error); process.exit(1);