feat: QR code dans script séparé show-qr.sh pour logs propres
- Création show-qr.sh : génère et affiche QR code avant lancement serveur - Détection auto mode dev/prod pour URL correcte - start.sh appelle show-qr.sh puis lance serveur silencieusement - Logs serveur uniquement dans server.log (terminal propre) - Suppression génération QR dans server/index.js (plus nécessaire) - Suppression dépendance qrcode-terminal dans server (utilisé via npx dans show-qr.sh)
This commit is contained in:
@@ -81,7 +81,7 @@ define(['./workbox-290dd570'], (function (workbox) { 'use strict';
|
||||
"revision": "3ca0b8505b4bec776b69afdba2768812"
|
||||
}, {
|
||||
"url": "index.html",
|
||||
"revision": "0.su9rr59m8gg"
|
||||
"revision": "0.spc2v3301v8"
|
||||
}], {});
|
||||
workbox.cleanupOutdatedCaches();
|
||||
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -21,8 +21,10 @@ class AudioBridgeManager extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Démarre le bridge audio avec la configuration actuelle
|
||||
* @param {Object} options - Options de démarrage
|
||||
* @param {string} options.liveKitUrl - URL LiveKit résolue (déjà avec IP si AUTO)
|
||||
*/
|
||||
async start() {
|
||||
async start(options = {}) {
|
||||
if (this.isRunning) {
|
||||
console.warn('⚠️ AudioBridge déjà démarré');
|
||||
return;
|
||||
@@ -83,11 +85,14 @@ class AudioBridgeManager extends EventEmitter {
|
||||
const inputDeviceId = audioConfig.device?.inputDeviceId || null;
|
||||
const outputDeviceId = audioConfig.device?.outputDeviceId || null;
|
||||
|
||||
// Utiliser l'URL résolue passée en option, sinon fallback config
|
||||
const liveKitUrl = options.liveKitUrl || config.server?.livekit?.url || 'ws://localhost:7880';
|
||||
|
||||
// Créer l'instance avec la config
|
||||
this.bridge = new AudioBridge({
|
||||
...audioConfig,
|
||||
// Options LiveKit
|
||||
liveKitUrl: config.server?.livekit?.url || 'ws://localhost:7880',
|
||||
liveKitUrl,
|
||||
liveKitToken,
|
||||
roomName: 'main',
|
||||
// Options de routing
|
||||
|
||||
+1
-14
@@ -9,7 +9,6 @@ import { dirname, join } from 'path';
|
||||
import { networkInterfaces } from 'os';
|
||||
import YAML from 'yaml';
|
||||
import { AccessToken } from 'livekit-server-sdk';
|
||||
import qrcode from 'qrcode-terminal';
|
||||
import adminRouter, { registerUser, addLog } from './api/admin.js';
|
||||
import configManager from './config/ConfigManager.js';
|
||||
import audioBridgeManager from './bridge/AudioBridgeManager.js';
|
||||
@@ -428,18 +427,6 @@ async function start() {
|
||||
log('info', ` Dev : ${clientUrl}`);
|
||||
log('info', ` Prod : ${prodUrl} (redirige → HTTPS)`);
|
||||
log('info', '');
|
||||
log('info', '📲 Scannez le QR code avec votre smartphone :');
|
||||
log('info', '');
|
||||
|
||||
// Générer QR code (utilise URL dev par défaut, ou prod si dist existe)
|
||||
const clientDistPath = join(__dirname, '..', 'client', 'dist');
|
||||
const qrUrl = existsSync(clientDistPath) ? prodUrl : clientUrl;
|
||||
|
||||
qrcode.generate(qrUrl, { small: true }, (qr) => {
|
||||
console.log(qr);
|
||||
});
|
||||
|
||||
log('info', '');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -451,7 +438,7 @@ async function start() {
|
||||
// 3. Démarrer Audio Bridge Manager (Phase 2.5)
|
||||
log('info', '');
|
||||
log('info', '🎵 Démarrage Audio Bridge Manager...');
|
||||
await audioBridgeManager.start();
|
||||
await audioBridgeManager.start({ liveKitUrl: LIVEKIT_URL });
|
||||
log('info', '✓ Audio Bridge Manager prêt (mode placeholder)');
|
||||
|
||||
// Gérer erreur port déjà utilisé
|
||||
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
# PTT Live - Affichage QR Code
|
||||
# Génère et affiche le QR code pour connexion smartphone
|
||||
|
||||
set -e
|
||||
|
||||
# Couleurs
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Détection IP réseau
|
||||
get_network_ip() {
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS
|
||||
ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | head -n 1
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# Linux
|
||||
hostname -I | awk '{print $1}'
|
||||
else
|
||||
echo "localhost"
|
||||
fi
|
||||
}
|
||||
|
||||
NETWORK_IP=$(get_network_ip)
|
||||
|
||||
# Déterminer l'URL selon mode dev ou prod
|
||||
if [ -d "client/dist" ] && [ "$1" != "--dev" ]; then
|
||||
# Mode production
|
||||
URL="http://${NETWORK_IP}:3000"
|
||||
MODE="production"
|
||||
else
|
||||
# Mode dev
|
||||
URL="https://${NETWORK_IP}:5173"
|
||||
MODE="dev"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${BLUE}=================================="
|
||||
echo "📱 QR Code PTT Live ($MODE)"
|
||||
echo "==================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Générer le QR code avec npx (pas besoin d'installer globalement)
|
||||
npx --yes qrcode-terminal "$URL" 2>/dev/null
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}🔗 URL : $URL${NC}"
|
||||
echo ""
|
||||
echo "📱 Scannez ce QR code depuis votre smartphone"
|
||||
echo " pour vous connecter instantanément"
|
||||
echo ""
|
||||
@@ -71,18 +71,34 @@ cleanup() {
|
||||
|
||||
trap cleanup SIGINT SIGTERM EXIT
|
||||
|
||||
# Démarrer le serveur (affiche QR code puis redirige vers log)
|
||||
# Afficher le QR code AVANT de lancer le serveur
|
||||
if [ "$1" == "--dev" ]; then
|
||||
./show-qr.sh --dev
|
||||
else
|
||||
./show-qr.sh
|
||||
fi
|
||||
|
||||
# Démarrer le serveur (silencieux, logs dans fichier)
|
||||
echo -e "${BLUE}🔧 Démarrage serveur...${NC}"
|
||||
echo ""
|
||||
|
||||
cd server
|
||||
|
||||
# Lancer le serveur avec tee pour capturer ET afficher la sortie
|
||||
npm start 2>&1 | tee ../server.log &
|
||||
# Lancer le serveur en background silencieux
|
||||
npm start > ../server.log 2>&1 &
|
||||
SERVER_PID=$!
|
||||
echo "$SERVER_PID" > "$PID_FILE"
|
||||
cd ..
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Attendre que le serveur soit prêt
|
||||
echo ""
|
||||
echo -e "${YELLOW}⏳ Attente démarrage serveur...${NC}"
|
||||
@@ -125,6 +141,8 @@ if [ "$1" == "--dev" ]; then
|
||||
echo "📊 API serveur : http://${NETWORK_IP}:3000 (→ redirige vers HTTPS)"
|
||||
echo "🎛️ Interface admin : https://${NETWORK_IP}:5173/admin"
|
||||
echo ""
|
||||
echo "📝 Logs serveur : tail -f server.log"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Appuyez sur Ctrl+C pour arrêter${NC}"
|
||||
echo ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user