ids.alfacom.it/deployment/check_frontend.sh
marco370 203eaa9a54 Improve system stability by fixing cron job and process monitoring
Refactor cron job execution to use separate shell scripts and update process monitoring scripts to correctly handle PID files and log directories.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: f6d4ec61-7130-41dd-aef9-87b4bc73d0e8
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/3R8dKMX
2025-11-18 08:33:05 +00:00

36 lines
942 B
Bash

#!/bin/bash
# =========================================================
# CHECK FRONTEND - Verifica e riavvia frontend Node.js se necessario
# =========================================================
PROCESS_NAME="npm run dev"
PID_FILE="/var/log/ids/frontend.pid"
LOG_FILE="/var/log/ids/frontend.log"
WORK_DIR="/opt/ids"
mkdir -p /var/log/ids
# Check if frontend is running
if pgrep -f "vite" > /dev/null; then
# Frontend running, update PID
pgrep -f "vite" > "$PID_FILE"
exit 0
else
echo "[$(date)] Frontend Node NON attivo, riavvio..." >> "$LOG_FILE"
# Kill any orphaned Node processes
pkill -f "vite" 2>/dev/null
pkill -f "npm run dev" 2>/dev/null
# Wait a moment
sleep 2
# Start frontend
cd "$WORK_DIR"
nohup npm run dev >> "$LOG_FILE" 2>&1 &
NEW_PID=$!
echo $NEW_PID > "$PID_FILE"
echo "[$(date)] Frontend riavviato con PID: $NEW_PID" >> "$LOG_FILE"
fi