Projektarbeit-MYP/frontend/start-debug-server.sh

55 lines
1.3 KiB
Bash

#!/bin/bash
# Farbcodes für Ausgabe
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Funktion zur Ausgabe mit Zeitstempel
log() {
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
}
error_log() {
echo -e "${RED}[$(date +'%Y-%m-%d %H:%M:%S')] FEHLER:${NC} $1" >&2
}
# Pfad zum Debug-Server
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DEBUG_SERVER_DIR="$SCRIPT_DIR/debug-server"
# Prüfe, ob das Debug-Server-Verzeichnis existiert
if [ ! -d "$DEBUG_SERVER_DIR" ]; then
error_log "Debug-Server-Verzeichnis nicht gefunden: $DEBUG_SERVER_DIR"
exit 1
fi
# Prüfe, ob Node.js installiert ist
if ! command -v node &> /dev/null; then
error_log "Node.js nicht gefunden. Bitte installieren Sie Node.js."
exit 1
fi
# Prüfe, ob npm installiert ist
if ! command -v npm &> /dev/null; then
error_log "npm nicht gefunden. Bitte installieren Sie npm."
exit 1
fi
# Wechsle ins Debug-Server-Verzeichnis
cd "$DEBUG_SERVER_DIR" || exit 1
# Installiere Abhängigkeiten, falls nötig
if [ -f "package.json" ]; then
log "Installiere Abhängigkeiten..."
npm install
fi
# Erstelle benötigte Verzeichnisse, falls sie nicht existieren
mkdir -p public/views
# Starte den Debug-Server
log "Starte Frontend-Debug-Server..."
node src/app.js