ids.alfacom.it/deployment/restart_frontend.sh
marco370 2f76875f2b Add systemd service for Node.js backend and update deployment scripts
Create `ids-backend.service` for the Node.js backend, modify `check_frontend.sh` to use systemd, and update `install_systemd_services.sh` to include the new service.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: 4484d762-7461-4e0f-bf71-fa7a7609e794
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/6WuDAR4
2026-02-17 07:47:24 +00:00

57 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
#
# Restart IDS Frontend (Node.js/Express)
# Utility per restart manuale del server frontend via systemd
#
set -e
echo "Restart Backend Node.js via systemd..."
# Stop servizio
echo "Stopping ids-backend..."
sudo systemctl stop ids-backend.service 2>/dev/null || true
sleep 2
# Kill eventuali processi orfani sulla porta 5000
echo "Liberando porta 5000..."
lsof -ti:5000 | xargs kill -9 2>/dev/null || true
sleep 1
# Verifica porta libera
if lsof -Pi :5000 -sTCP:LISTEN -t >/dev/null 2>&1; then
echo "ERRORE: Porta 5000 ancora occupata!"
echo "Processi sulla porta:"
lsof -i:5000
exit 1
fi
echo "Porta 5000 libera"
# Start servizio
echo "Starting ids-backend..."
sudo systemctl start ids-backend.service
# Attendi avvio completo
sleep 5
# Verifica avvio
if systemctl is-active --quiet ids-backend.service; then
echo "Backend avviato con successo"
echo "Server disponibile su: http://localhost:5000"
# Test rapido
sleep 2
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/ 2>/dev/null || echo "000")
if [ "$HTTP_CODE" = "200" ]; then
echo "HTTP test OK (200)"
else
echo "HTTP test: $HTTP_CODE (potrebbe essere in fase di avvio)"
fi
else
echo "ERRORE: Backend non avviato!"
echo "Controlla log: journalctl -u ids-backend -n 20"
sudo journalctl -u ids-backend -n 20 --no-pager
exit 1
fi