Compare commits

..

No commits in common. "ee15efc8982be7748f479c85742c89031cfd31f5" and "659af9abc0ac4047e196f3ca3655bed07aed7672" have entirely different histories.

3 changed files with 14 additions and 45 deletions

View File

@ -354,18 +354,13 @@ fi
# Test API-Endpunkt # Test API-Endpunkt
log "${YELLOW}Teste Backend-API...${NC}" log "${YELLOW}Teste Backend-API...${NC}"
log "${YELLOW}HINWEIS: Der API-Server ist bei der ersten Installation oft noch nicht erreichbar${NC}" if curl -s http://localhost:5000/health | grep -q "healthy"; then
log "${YELLOW}Dies ist ein bekanntes Verhalten wegen der Netzwerkkonfiguration${NC}"
log "${YELLOW}Bitte nach der Installation das System neu starten, danach sollte der API-Server erreichbar sein${NC}"
# Wir versuchen es trotzdem einmal, um zu sehen, ob er vielleicht doch läuft
if curl -s http://localhost:5000/health 2>/dev/null | grep -q "healthy"; then
log "${GREEN}Backend-API ist erreichbar und funktioniert${NC}" log "${GREEN}Backend-API ist erreichbar und funktioniert${NC}"
else else
log "${YELLOW}Backend-API ist wie erwartet noch nicht erreichbar${NC}" error_log "Backend-API ist nicht erreichbar. HTTP-Status:"
log "${GREEN}Das ist völlig normal bei der Erstinstallation${NC}" curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/health
log "${GREEN}Nach einem Neustart des Systems sollte der API-Server korrekt erreichbar sein${NC}" log "Container-Logs:"
log "Container-Status prüfen mit: docker logs myp-backend" docker logs myp-backend
fi fi
# Initialisierung der Datenbank prüfen # Initialisierung der Datenbank prüfen
@ -396,8 +391,7 @@ else
fi fi
log "${GREEN}=== Installation abgeschlossen ===${NC}" log "${GREEN}=== Installation abgeschlossen ===${NC}"
log "${YELLOW}WICHTIG: Nach der Erstinstallation ist ein Systemneustart erforderlich${NC}" log "Das Backend ist unter http://localhost:5000 erreichbar"
log "${YELLOW}Danach ist das Backend unter http://localhost:5000 erreichbar${NC}"
log "Anzeigen der Logs: docker logs -f myp-backend" log "Anzeigen der Logs: docker logs -f myp-backend"
# Verwende die richtige Docker Compose Version für Hinweis # Verwende die richtige Docker Compose Version für Hinweis

View File

@ -396,38 +396,19 @@ done
# Teste ob der Server erreichbar ist # Teste ob der Server erreichbar ist
log "${YELLOW}Teste ob Frontend-Server erreichbar ist...${NC}" log "${YELLOW}Teste ob Frontend-Server erreichbar ist...${NC}"
log "${YELLOW}HINWEIS: Bei der Erstinstallation kann es einige Minuten dauern, bis der Server erreichbar ist${NC}" MAX_ATTEMPTS=12
log "${YELLOW}Bei anhaltenden Problemen kann ein Neustart des Systems helfen${NC}"
MAX_ATTEMPTS=3
ATTEMPT=1 ATTEMPT=1
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
log "Versuch $ATTEMPT/$MAX_ATTEMPTS..." log "Versuch $ATTEMPT/$MAX_ATTEMPTS..."
if curl -s -o /dev/null -w "%{http_code}" http://localhost:3000 2>/dev/null | grep -q "200\|304"; then if curl -s -o /dev/null -w "%{http_code}" http://localhost:3000 | grep -q "200\|304"; then
log "${GREEN}Frontend-Server ist erreichbar!${NC}" log "${GREEN}Frontend-Server ist erreichbar!${NC}"
break break
else else
# Prüfe, ob der Container noch läuft oder Fehler aufweist
CONTAINER_STATUS=$(docker inspect --format='{{.State.Status}}' myp-frontend 2>/dev/null || echo "nicht gefunden")
if [ "$CONTAINER_STATUS" != "running" ]; then
log "${YELLOW}Container ist nicht aktiv (Status: $CONTAINER_STATUS). Prüfe Logs...${NC}"
docker logs myp-frontend --tail 20
# Wenn der Container gestoppt wurde, starte ihn neu
if [ "$CONTAINER_STATUS" = "exited" ] || [ "$CONTAINER_STATUS" = "created" ]; then
log "${YELLOW}Versuche, den Container neuzustarten...${NC}"
docker start myp-frontend
sleep 10
fi
fi
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
log "${YELLOW}Server noch nicht erreichbar. Das ist bei der Erstinstallation normal.${NC}" log "${YELLOW}Server noch nicht erreichbar. Das ist normal, wenn der Next.js-Build länger dauert.${NC}"
log "${GREEN}Der Container ist installiert und sollte nach einem System-Neustart korrekt funktionieren.${NC}" log "Überprüfen Sie den Container-Status mit: docker logs myp-frontend"
log "${GREEN}Beim ersten Start kann die Datenbank-Migration und der Build länger dauern.${NC}" log "Der Server sollte in wenigen Minuten verfügbar sein."
log "Überprüfen Sie später den Container-Status mit: docker logs myp-frontend"
else else
log "Server noch nicht erreichbar. Warte 10 Sekunden..." log "Server noch nicht erreichbar. Warte 10 Sekunden..."
sleep 10 sleep 10
@ -456,8 +437,7 @@ else
fi fi
log "${GREEN}=== Installation abgeschlossen ===${NC}" log "${GREEN}=== Installation abgeschlossen ===${NC}"
log "${YELLOW}WICHTIG: Nach der Erstinstallation ist ein Systemneustart erforderlich${NC}" log "Das Frontend ist unter http://localhost:3000 erreichbar"
log "${YELLOW}Danach ist das Frontend unter http://localhost:3000 erreichbar${NC}"
log "Anzeigen der Logs: docker logs -f myp-frontend" log "Anzeigen der Logs: docker logs -f myp-frontend"
# Verwende die richtige Docker Compose Version für Hinweis # Verwende die richtige Docker Compose Version für Hinweis

View File

@ -36,15 +36,10 @@ RUN echo '#!/bin/sh' > /app/startup.sh && \
echo 'mkdir -p /app/db' >> /app/startup.sh && \ echo 'mkdir -p /app/db' >> /app/startup.sh && \
echo 'echo "Starting application..."' >> /app/startup.sh && \ echo 'echo "Starting application..."' >> /app/startup.sh && \
echo 'echo "Attempting database migration..."' >> /app/startup.sh && \ echo 'echo "Attempting database migration..."' >> /app/startup.sh && \
echo 'DB_FILE="/app/db/sqlite.db"' >> /app/startup.sh && \ echo 'NODE_ENV=production node -e "const { migrate } = require(\"drizzle-orm/better-sqlite3/migrator\"); const { db } = require(\"./src/server/db/index.js\"); try { console.log(\"Running migrations...\"); migrate(db, { migrationsFolder: \"./drizzle\" }); console.log(\"Migrations completed\"); } catch(e) { console.error(\"Migration error:\", e); }"' >> /app/startup.sh && \
echo 'if [ ! -f "$DB_FILE" ]; then' >> /app/startup.sh && \
echo ' echo "Creating empty database file..."' >> /app/startup.sh && \
echo ' touch "$DB_FILE"' >> /app/startup.sh && \
echo 'fi' >> /app/startup.sh && \
echo 'NODE_ENV=production npx tsx ./src/server/db/migrate.ts || echo "Migration failed but continuing..."' >> /app/startup.sh && \
echo 'echo "Migration completed or skipped"' >> /app/startup.sh && \ echo 'echo "Migration completed or skipped"' >> /app/startup.sh && \
echo 'pnpm build || echo "Build failed, but continuing with existing build..."' >> /app/startup.sh && \ echo 'pnpm build || echo "Build failed, but continuing with existing build..."' >> /app/startup.sh && \
echo 'pnpm start || pnpm dev' >> /app/startup.sh && \ echo 'pnpm start' >> /app/startup.sh && \
chmod +x /app/startup.sh chmod +x /app/startup.sh
# Start the application # Start the application