ids.alfacom.it/attached_assets/Pasted--deployment-run-analytics-sh-hourly-Esecuzione-aggregazione-hourly-ANALYTICS-Aggregazione-or-1763978174308_1763978174308.txt
marco370 e629bf4ed3 Improve analytics data fetching and server restart process
Fixes the analytics API call by correctly formatting the query parameters in the `AnalyticsHistory.tsx` component. Enhances the `restart_frontend.sh` script for more aggressive process killing and port cleanup to prevent 'address already in use' errors. Also, adds a check for the `country` column existence in the database schema, addressing a potential mismatch between development and production environments.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 23dd17a9-47b9-4533-bf4c-8b5cfdb426b4
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/x5P9dcJ
2025-11-24 09:59:06 +00:00

254 lines
8.8 KiB
Plaintext

./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