#!/bin/bash # ========================================================= # CHECK FRONTEND - Verifica e riavvia frontend Node.js se necessario # Usa systemctl per gestire il servizio # ========================================================= LOG_FILE="/var/log/ids/frontend.log" mkdir -p /var/log/ids # Check if systemd service is active if systemctl is-active --quiet ids-frontend; then exit 0 else echo "[$(date)] Frontend Node NON attivo, riavvio via systemctl..." >> "$LOG_FILE" # Restart via systemctl systemctl restart ids-frontend # Wait for startup sleep 3 if systemctl is-active --quiet ids-frontend; then echo "[$(date)] Frontend riavviato con successo via systemctl" >> "$LOG_FILE" else echo "[$(date)] ERRORE: Frontend non si รจ avviato. Controlla: journalctl -u ids-frontend" >> "$LOG_FILE" fi fi