diff --git a/.replit b/.replit index 5c190e2..f32bcdc 100644 --- a/.replit +++ b/.replit @@ -14,6 +14,10 @@ run = ["npm", "run", "start"] localPort = 5000 externalPort = 80 +[[ports]] +localPort = 35845 +externalPort = 3001 + [[ports]] localPort = 41303 externalPort = 3002 diff --git a/attached_assets/Pasted--deployment-run-analytics-sh-hourly-Esecuzione-aggregazione-hourly-ANALYTICS-Aggregazione-or-1763978174308_1763978174308.txt b/attached_assets/Pasted--deployment-run-analytics-sh-hourly-Esecuzione-aggregazione-hourly-ANALYTICS-Aggregazione-or-1763978174308_1763978174308.txt new file mode 100644 index 0000000..074602d --- /dev/null +++ b/attached_assets/Pasted--deployment-run-analytics-sh-hourly-Esecuzione-aggregazione-hourly-ANALYTICS-Aggregazione-or-1763978174308_1763978174308.txt @@ -0,0 +1,254 @@ +./deployment/run_analytics.sh hourly + Esecuzione aggregazione hourly... +[ANALYTICS] Aggregazione oraria: 2025-11-24 09:00 +[ANALYTICS] ✅ Aggregazione completata: + - Totale: 7182065 pacchetti, 27409 IP unici + - Normale: 6922072 pacchetti (96%) + - Attacchi: 259993 pacchetti (3%), 15 IP +✅ Aggregazione hourly completata! +[root@ids ids]# ./deployment/restart_frontend.sh + Restart Frontend Node.js... +⏸ Stopping existing processes... + Starting frontend... +❌ Errore: Frontend non avviato! + Controlla log: tail -f /var/log/ids/frontend.log +[root@ids ids]# curl -s http://localhost:5000/api/analytics/recent?days=7&hourly=true | jq '. | length' +[1] 59354 +[root@ids ids]# echo "=== DIAGNOSTICA IDS ANALYTICS ===" > /tmp/ids_diagnostic.txtxt +echo "" >> /tmp/ids_diagnostic.txt +[1]+ Done curl -s http://localhost:5000/api/analytics/recent?days=7 +[root@ids ids]# tail -f /var/log/ids/frontend.log +[Mon Nov 24 10:15:13 CET 2025] Frontend Node NON attivo, riavvio... +[Mon Nov 24 10:15:15 CET 2025] Frontend riavviato con PID: 59307 + +> rest-express@1.0.0 dev +> NODE_ENV=development tsx server/index.ts + + Using standard PostgreSQL database +10:15:17 AM [express] serving on port 5000 +✅ Database connection successful +10:15:34 AM [express] GET /api/analytics/recent 200 in 32ms :: [] +[Mon Nov 24 10:20:01 CET 2025] Frontend Node NON attivo, riavvio... +[Mon Nov 24 10:20:03 CET 2025] Frontend riavviato con PID: 59406 + +> rest-express@1.0.0 dev +> NODE_ENV=development tsx server/index.ts + + Using standard PostgreSQL database +node:events:502 + throw er; // Unhandled 'error' event + ^ + +Error: listen EADDRINUSE: address already in use 0.0.0.0:5000 + at Server.setupListenHandle [as _listen2] (node:net:1908:16) + at listenInCluster (node:net:1965:12) + at doListen (node:net:2139:7) + at process.processTicksAndRejections (node:internal/process/task_queues:83:21) +Emitted 'error' event on Server instance at: + at emitErrorNT (node:net:1944:8) + at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 5000 +} + +Node.js v20.19.5 +[Mon Nov 24 10:25:02 CET 2025] Frontend Node NON attivo, riavvio... +[Mon Nov 24 10:25:04 CET 2025] Frontend riavviato con PID: 59511 + +> rest-express@1.0.0 dev +> NODE_ENV=development tsx server/index.ts + + Using standard PostgreSQL database +node:events:502 + throw er; // Unhandled 'error' event + ^ + +Error: listen EADDRINUSE: address already in use 0.0.0.0:5000 + at Server.setupListenHandle [as _listen2] (node:net:1908:16) + at listenInCluster (node:net:1965:12) + at doListen (node:net:2139:7) + at process.processTicksAndRejections (node:internal/process/task_queues:83:21) +Emitted 'error' event on Server instance at: + at emitErrorNT (node:net:1944:8) + at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 5000 +} + +Node.js v20.19.5 +[Mon Nov 24 10:30:01 CET 2025] Frontend Node NON attivo, riavvio... +[Mon Nov 24 10:30:03 CET 2025] Frontend riavviato con PID: 59618 + +> rest-express@1.0.0 dev +> NODE_ENV=development tsx server/index.ts + + Using standard PostgreSQL database +node:events:502 + throw er; // Unhandled 'error' event + ^ + +Error: listen EADDRINUSE: address already in use 0.0.0.0:5000 + at Server.setupListenHandle [as _listen2] (node:net:1908:16) + at listenInCluster (node:net:1965:12) + at doListen (node:net:2139:7) + at process.processTicksAndRejections (node:internal/process/task_queues:83:21) +Emitted 'error' event on Server instance at: + at emitErrorNT (node:net:1944:8) + at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 5000 +} + +Node.js v20.19.5 +[Mon Nov 24 10:35:01 CET 2025] Frontend Node NON attivo, riavvio... +[Mon Nov 24 10:35:03 CET 2025] Frontend riavviato con PID: 59725 + +> rest-express@1.0.0 dev +> NODE_ENV=development tsx server/index.ts + + Using standard PostgreSQL database +node:events:502 + throw er; // Unhandled 'error' event + ^ + +Error: listen EADDRINUSE: address already in use 0.0.0.0:5000 + at Server.setupListenHandle [as _listen2] (node:net:1908:16) + at listenInCluster (node:net:1965:12) + at doListen (node:net:2139:7) + at process.processTicksAndRejections (node:internal/process/task_queues:83:21) +Emitted 'error' event on Server instance at: + at emitErrorNT (node:net:1944:8) + at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 5000 +} + +Node.js v20.19.5 +[Mon Nov 24 10:40:02 CET 2025] Frontend Node NON attivo, riavvio... +[Mon Nov 24 10:40:04 CET 2025] Frontend riavviato con PID: 59831 + +> rest-express@1.0.0 dev +> NODE_ENV=development tsx server/index.ts + + Using standard PostgreSQL database +node:events:502 + throw er; // Unhandled 'error' event + ^ + +Error: listen EADDRINUSE: address already in use 0.0.0.0:5000 + at Server.setupListenHandle [as _listen2] (node:net:1908:16) + at listenInCluster (node:net:1965:12) + at doListen (node:net:2139:7) + at process.processTicksAndRejections (node:internal/process/task_queues:83:21) +Emitted 'error' event on Server instance at: + at emitErrorNT (node:net:1944:8) + at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 5000 +} + +Node.js v20.19.5 +[Mon Nov 24 10:45:02 CET 2025] Frontend Node NON attivo, riavvio... +[Mon Nov 24 10:45:04 CET 2025] Frontend riavviato con PID: 59935 + +> rest-express@1.0.0 dev +> NODE_ENV=development tsx server/index.ts + + Using standard PostgreSQL database +node:events:502 + throw er; // Unhandled 'error' event + ^ + +Error: listen EADDRINUSE: address already in use 0.0.0.0:5000 + at Server.setupListenHandle [as _listen2] (node:net:1908:16) + at listenInCluster (node:net:1965:12) + at doListen (node:net:2139:7) + at process.processTicksAndRejections (node:internal/process/task_queues:83:21) +Emitted 'error' event on Server instance at: + at emitErrorNT (node:net:1944:8) + at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 5000 +} + +Node.js v20.19.5 +[Mon Nov 24 10:50:01 CET 2025] Frontend Node NON attivo, riavvio... +[Mon Nov 24 10:50:03 CET 2025] Frontend riavviato con PID: 60044 + +> rest-express@1.0.0 dev +> NODE_ENV=development tsx server/index.ts + + Using standard PostgreSQL database +node:events:502 + throw er; // Unhandled 'error' event + ^ + +Error: listen EADDRINUSE: address already in use 0.0.0.0:5000 + at Server.setupListenHandle [as _listen2] (node:net:1908:16) + at listenInCluster (node:net:1965:12) + at doListen (node:net:2139:7) + at process.processTicksAndRejections (node:internal/process/task_queues:83:21) +Emitted 'error' event on Server instance at: + at emitErrorNT (node:net:1944:8) + at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 5000 +} + +Node.js v20.19.5 +[Mon Nov 24 10:55:01 CET 2025] Frontend Node NON attivo, riavvio... +[Mon Nov 24 10:55:03 CET 2025] Frontend riavviato con PID: 60151 + +> rest-express@1.0.0 dev +> NODE_ENV=development tsx server/index.ts + + +A PostCSS plugin did not pass the `from` option to `postcss.parse`. This may cause imported assets to be incorrectly transformed. If you've recently added a PostCSS plugin that raised this warning, please contact the package author to fix the issue. +🐘 Using standard PostgreSQL database +node:events:502 + throw er; // Unhandled 'error' event + ^ + +Error: listen EADDRINUSE: address already in use 0.0.0.0:5000 + at Server.setupListenHandle [as _listen2] (node:net:1908:16) + at listenInCluster (node:net:1965:12) + at doListen (node:net:2139:7) + at process.processTicksAndRejections (node:internal/process/task_queues:83:21) +Emitted 'error' event on Server instance at: + at emitErrorNT (node:net:1944:8) + at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { + code: 'EADDRINUSE', + errno: -98, + syscall: 'listen', + address: '0.0.0.0', + port: 5000 +} + +Node.js v20.19.5 +10:55:06 AM [express] GET /api/logs/[object%20Object] 200 in 10ms +10:55:06 AM [express] GET /api/detections 200 in 34ms :: [{"id":"5659c0b5-11df-4ebe-b73f-f53c64932953… +10:55:08 AM [express] GET /api/analytics/recent/[object%20Object] 200 in 7ms +10:55:11 AM [express] GET /api/analytics/recent/[object%20Object] 200 in 5ms +10:55:12 AM [express] GET /api/analytics/recent/[object%20Object] 200 in 5ms + \ No newline at end of file diff --git a/client/src/pages/AnalyticsHistory.tsx b/client/src/pages/AnalyticsHistory.tsx index 0a2e176..13617ed 100644 --- a/client/src/pages/AnalyticsHistory.tsx +++ b/client/src/pages/AnalyticsHistory.tsx @@ -14,9 +14,9 @@ import { useState } from "react"; export default function AnalyticsHistory() { const [days, setDays] = useState(30); - // Fetch historical analytics (daily aggregations) + // Fetch historical analytics (hourly aggregations) const { data: analytics = [], isLoading } = useQuery({ - queryKey: ["/api/analytics/recent", { days, hourly: true }], + queryKey: [`/api/analytics/recent?days=${days}&hourly=true`], refetchInterval: 60000, // Aggiorna ogni minuto }); diff --git a/deployment/restart_frontend.sh b/deployment/restart_frontend.sh index 01dc15d..8612489 100755 --- a/deployment/restart_frontend.sh +++ b/deployment/restart_frontend.sh @@ -8,31 +8,49 @@ set -e echo "🔄 Restart Frontend Node.js..." -# Kill processi Vite esistenti -echo "⏸️ Stopping existing processes..." -pkill -f "vite" 2>/dev/null || true -pkill -f "npm run dev" 2>/dev/null || true +# Kill AGGRESSIVO di tutti i processi Node/Vite +echo "⏸️ Stopping all Node/Vite processes..." +pkill -9 -f "node.*tsx" 2>/dev/null || true +pkill -9 -f "vite" 2>/dev/null || true +pkill -9 -f "npm run dev" 2>/dev/null || true sleep 2 -# Verifica porta 5000 libera +# Kill processo sulla porta 5000 (se esiste) +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 "⚠️ Porta 5000 occupata, killing processo..." - lsof -ti:5000 | xargs kill -9 2>/dev/null || true - sleep 1 + echo "❌ ERRORE: Porta 5000 ancora occupata!" + echo "Processi sulla porta:" + lsof -i:5000 + exit 1 fi +echo "✅ Porta 5000 libera" + # Restart usando check_frontend.sh echo "🚀 Starting frontend..." /opt/ids/deployment/check_frontend.sh -# Attendi avvio -sleep 3 +# Attendi avvio completo +sleep 5 -# Verifica +# Verifica avvio if pgrep -f "vite" > /dev/null; then PID=$(pgrep -f "vite") echo "✅ Frontend avviato con PID: $PID" 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" + fi else echo "❌ Errore: Frontend non avviato!" echo "📋 Controlla log: tail -f /var/log/ids/frontend.log"