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

52 lines
1.2 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 Python installiert ist
if ! command -v python &> /dev/null; then
error_log "Python nicht gefunden. Bitte installieren Sie Python."
exit 1
fi
# Prüfe, ob pip installiert ist
if ! command -v pip &> /dev/null; then
error_log "pip nicht gefunden. Bitte installieren Sie pip."
exit 1
fi
# Wechsle ins Debug-Server-Verzeichnis
cd "$DEBUG_SERVER_DIR" || exit 1
# Installiere Abhängigkeiten, falls nötig
if [ -f "requirements.txt" ]; then
log "Installiere Abhängigkeiten..."
pip install -r requirements.txt
fi
# Starte den Debug-Server
log "Starte Backend-Debug-Server..."
python app.py