feat: install LiveKit via Homebrew et simplifie configuration

- Remplace téléchargement binaire par installation Homebrew
- Utilise clés par défaut devkey/secret en mode --dev
- Supprime flags incompatibles (--rtc-port-range-*, --port)
- Ajoute détection/mise à jour LiveKit existant
- Simplifie lancement automatique depuis Node.js

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-05-22 22:10:37 +02:00
parent 3afb82355e
commit 8bae2f03bf
3 changed files with 56 additions and 52 deletions
+35 -40
View File
@@ -38,46 +38,41 @@ fi
echo -e "${GREEN}✅ npm $(npm -v)${NC}" echo -e "${GREEN}✅ npm $(npm -v)${NC}"
echo "" echo ""
# Télécharger LiveKit Server # Vérifier Homebrew
LIVEKIT_VERSION="v1.7.2" echo "🍺 Vérification Homebrew..."
LIVEKIT_URL="https://github.com/livekit/livekit/releases/download/${LIVEKIT_VERSION}/livekit_${LIVEKIT_VERSION}_darwin_amd64.tar.gz" if ! command -v brew &> /dev/null; then
LIVEKIT_ARM_URL="https://github.com/livekit/livekit/releases/download/${LIVEKIT_VERSION}/livekit_${LIVEKIT_VERSION}_darwin_arm64.tar.gz" echo -e "${RED}❌ Homebrew n'est pas installé${NC}"
echo " Installez Homebrew depuis https://brew.sh"
echo "📥 Téléchargement LiveKit Server ${LIVEKIT_VERSION}..." echo " Ou exécutez :"
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
# Détecter architecture (Intel vs Apple Silicon) exit 1
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ]; then
echo " Architecture: Apple Silicon (ARM64)"
DOWNLOAD_URL=$LIVEKIT_ARM_URL
else
echo " Architecture: Intel (AMD64)"
DOWNLOAD_URL=$LIVEKIT_URL
fi fi
cd server/bin echo -e "${GREEN}✅ Homebrew $(brew --version | head -n 1)${NC}"
if [ -f "livekit-server" ]; then
echo -e "${YELLOW}⚠️ LiveKit Server déjà présent, suppression...${NC}"
rm -f livekit-server
fi
# Télécharger et extraire
curl -L -o livekit.tar.gz "$DOWNLOAD_URL"
tar -xzf livekit.tar.gz
rm livekit.tar.gz
# Rendre exécutable
chmod +x livekit-server
echo -e "${GREEN}✅ LiveKit Server installé${NC}"
echo "" echo ""
cd ../.. # Installer LiveKit Server via Homebrew
echo "📥 Installation LiveKit Server..."
if command -v livekit-server &> /dev/null; then
CURRENT_VERSION=$(livekit-server --version 2>&1 | head -n 1 || echo "version inconnue")
echo -e "${YELLOW}⚠️ LiveKit Server déjà installé ($CURRENT_VERSION)${NC}"
read -p " Mettre à jour ? (o/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Oo]$ ]]; then
brew upgrade livekit
echo -e "${GREEN}✅ LiveKit Server mis à jour${NC}"
else
echo -e "${GREEN}✅ LiveKit Server existant conservé${NC}"
fi
else
brew install livekit
echo -e "${GREEN}✅ LiveKit Server installé${NC}"
fi
echo ""
# Installer dépendances serveur # Installer dépendances serveur
echo "📦 Installation dépendances serveur..." echo "📦 Installation dépendances serveur..."
cd server cd ../server
npm install npm install
echo -e "${GREEN}✅ Dépendances serveur installées${NC}" echo -e "${GREEN}✅ Dépendances serveur installées${NC}"
echo "" echo ""
@@ -91,17 +86,17 @@ echo ""
cd .. cd ..
# Générer clés API LiveKit
echo "🔑 Génération clés API LiveKit..."
API_KEY="APIkey$(openssl rand -hex 16)"
API_SECRET=$(openssl rand -base64 32)
# Créer fichier .env # Créer fichier .env
echo "🔑 Génération configuration LiveKit..."
cat > server/.env << EOF cat > server/.env << EOF
USE_LOCAL_LIVEKIT=true
# LiveKit Configuration # LiveKit Configuration
LIVEKIT_URL=ws://localhost:7880 LIVEKIT_URL=ws://localhost:7880
LIVEKIT_API_KEY=$API_KEY # En mode --dev, LiveKit utilise ces clés par défaut
LIVEKIT_API_SECRET=$API_SECRET LIVEKIT_API_KEY=devkey
LIVEKIT_API_SECRET=secret
# Server Configuration # Server Configuration
PORT=3000 PORT=3000
+11 -9
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env node #!/usr/bin/env node
import 'dotenv/config';
import express from 'express'; import express from 'express';
import { spawn } from 'child_process'; import { spawn } from 'child_process';
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
@@ -43,25 +44,26 @@ let livekitProcess = null;
function startLiveKitServer() { function startLiveKitServer() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const livekitBinary = join(__dirname, 'bin', 'livekit-server'); // Utiliser le binaire Homebrew (dans PATH)
const livekitBinary = 'livekit-server';
log('info', 'Démarrage LiveKit Server...'); log('info', 'Démarrage LiveKit Server...');
log('debug', 'Binaire:', livekitBinary); log('debug', 'Commande:', livekitBinary);
log('debug', 'URL:', LIVEKIT_URL); log('debug', 'URL:', LIVEKIT_URL);
// Configuration LiveKit en arguments // Configuration LiveKit en arguments
// En mode --dev, LiveKit utilise automatiquement devkey/secret
const args = [ const args = [
'--dev', // Mode développement '--dev', // Mode développement (active debug + clés par défaut devkey/secret)
'--bind', '0.0.0.0', '--bind', '0.0.0.0'
'--port', '7880', // Note: --udp-port peut être ajouté si besoin (ex: --udp-port 7882)
'--rtc-port-range-start', '50000', // Le port HTTP/WebSocket est 7880 par défaut
'--rtc-port-range-end', '60000',
'--keys', `${LIVEKIT_API_KEY}: ${LIVEKIT_API_SECRET}`
]; ];
livekitProcess = spawn(livekitBinary, args, { livekitProcess = spawn(livekitBinary, args, {
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
env: { ...process.env } env: { ...process.env },
shell: true // Permet de trouver le binaire dans PATH
}); });
livekitProcess.stdout.on('data', (data) => { livekitProcess.stdout.on('data', (data) => {
+10 -3
View File
@@ -9,14 +9,21 @@
"dev": "node --watch index.js", "dev": "node --watch index.js",
"test": "node --test" "test": "node --test"
}, },
"keywords": ["webrtc", "intercom", "livekit", "audio", "ptt"], "keywords": [
"webrtc",
"intercom",
"livekit",
"audio",
"ptt"
],
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"dotenv": "^17.4.2",
"express": "^4.19.2", "express": "^4.19.2",
"livekit-server-sdk": "^2.6.0", "livekit-server-sdk": "^2.6.0",
"yaml": "^2.4.2", "ws": "^8.17.0",
"ws": "^8.17.0" "yaml": "^2.4.2"
}, },
"devDependencies": { "devDependencies": {
"nodemon": "^3.1.0" "nodemon": "^3.1.0"