Adjusted `check_frontend.sh` and `restart_all.sh` to use `systemctl` for the ML backend and direct process management for the frontend, resolving issues with incorrect Python environments and process termination. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: cb6e0872-24a9-4a4b-a053-9491c053b13f Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/4aeldgV
34 lines
1021 B
Bash
Executable File
34 lines
1021 B
Bash
Executable File
#!/bin/bash
|
|
# =========================================================
|
|
# CHECK FRONTEND - Verifica e riavvia frontend Node.js se necessario
|
|
# =========================================================
|
|
|
|
LOG_FILE="/var/log/ids/frontend.log"
|
|
WORK_DIR="/opt/ids"
|
|
|
|
mkdir -p /var/log/ids
|
|
|
|
# Check if frontend (vite/node) is running
|
|
if pgrep -f "vite" > /dev/null || pgrep -f "node.*server" > /dev/null; then
|
|
exit 0
|
|
else
|
|
echo "[$(date)] Frontend Node NON attivo, riavvio..." >> "$LOG_FILE"
|
|
|
|
# Start frontend with environment variables from .env
|
|
cd "$WORK_DIR"
|
|
if [ -f "$WORK_DIR/.env" ]; then
|
|
nohup env $(cat "$WORK_DIR/.env" | grep -v '^#' | xargs) npm run dev >> "$LOG_FILE" 2>&1 &
|
|
else
|
|
nohup npm run dev >> "$LOG_FILE" 2>&1 &
|
|
fi
|
|
NEW_PID=$!
|
|
|
|
sleep 3
|
|
|
|
if pgrep -f "vite" > /dev/null; then
|
|
echo "[$(date)] Frontend riavviato con successo (PID: $NEW_PID)" >> "$LOG_FILE"
|
|
else
|
|
echo "[$(date)] ERRORE: Frontend non si è avviato" >> "$LOG_FILE"
|
|
fi
|
|
fi
|