 ./update_from_git.sh --db

╔═══════════════════════════════════════════════╗
║    AGGIORNAMENTO SISTEMA IDS DA GIT         ║
╚═══════════════════════════════════════════════╝

 Verifica configurazione git...

 Backup configurazione locale...
✅ .env salvato in .env.backup

 Verifica modifiche locali...
⚠  Ci sono modifiche locali non committate
   Esegui 'git status' per vedere i dettagli
Vuoi procedere comunque? (y/n) y
   Salvo modifiche locali temporaneamente...
Saved working directory and index state WIP on main: 40990d4  Release v1.0.21

 Download aggiornamenti da git.alfacom.it...
From https://git.alfacom.it/marco/ids.alfacom.it
 * branch            main       -> FETCH_HEAD
Already up to date.
✅ Aggiornamenti scaricati con successo

 Ripristino configurazione locale...
✅ .env ripristinato

  Sincronizzazione schema database...
⚠  APPLICAZIONE MODIFICHE AL DATABASE
   Database: ids_database@localhost
   Script da applicare:
     • create_detections.sql
     • create_network_logs.sql
     • create_routers.sql
     • create_training_history.sql
     • create_whitelist.sql
Confermi applicazione modifiche? (y/n) y

 Applicando create_detections.sql...
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
CREATE INDEX
COMMENT
                 status
-----------------------------------------
 Tabella detections creata con successo!
(1 row)

✅ create_detections.sql applicato con successo

 Applicando create_network_logs.sql...
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
CREATE INDEX
COMMENT
                  status
-------------------------------------------
 Tabella network_logs creata con successo!
(1 row)

✅ create_network_logs.sql applicato con successo

 Applicando create_routers.sql...
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
COMMENT
INSERT 0 1
                status
--------------------------------------
 Tabella routers creata con successo!
(1 row)

✅ create_routers.sql applicato con successo

 Applicando create_training_history.sql...
DROP TABLE
CREATE TABLE
CREATE INDEX
COMMENT
                    status
-----------------------------------------------
 Tabella training_history creata con successo!
(1 row)

✅ create_training_history.sql applicato con successo

 Applicando create_whitelist.sql...
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
COMMENT
                 status
----------------------------------------
 Tabella whitelist creata con successo!
(1 row)

✅ create_whitelist.sql applicato con successo

✅ Tutti gli script SQL applicati con successo

 Aggiornamento dipendenze Node.js...

up to date, audited 492 packages in 4s

65 packages are looking for funding
  run `npm fund` for details

9 vulnerabilities (3 low, 5 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
✅ Dipendenze Node.js aggiornate

 Aggiornamento dipendenze Python...
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: fastapi==0.104.1 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 1)) (0.104.1)
Requirement already satisfied: uvicorn==0.24.0 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 2)) (0.24.0)
Requirement already satisfied: pandas==2.1.3 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 3)) (2.1.3)
Requirement already satisfied: numpy==1.26.2 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 4)) (1.26.2)
Requirement already satisfied: scikit-learn==1.3.2 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 5)) (1.3.2)
Requirement already satisfied: psycopg2-binary==2.9.9 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 6)) (2.9.9)
Requirement already satisfied: python-dotenv==1.0.0 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 7)) (1.0.0)
Requirement already satisfied: pydantic==2.5.0 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 8)) (2.5.0)
Requirement already satisfied: httpx==0.25.1 in /home/ids/.local/lib/python3.11/site-packages (from -r requirements.txt (line 9)) (0.25.1)
Requirement already satisfied: anyio<4.0.0,>=3.7.1 in /home/ids/.local/lib/python3.11/site-packages (from fastapi==0.104.1->-r requirements.txt (line 1)) (3.7.1)
Requirement already satisfied: starlette<0.28.0,>=0.27.0 in /home/ids/.local/lib/python3.11/site-packages (from fastapi==0.104.1->-r requirements.txt (line 1)) (0.27.0)
Requirement already satisfied: typing-extensions>=4.8.0 in /home/ids/.local/lib/python3.11/site-packages (from fastapi==0.104.1->-r requirements.txt (line 1)) (4.15.0)
Requirement already satisfied: click>=7.0 in /home/ids/.local/lib/python3.11/site-packages (from uvicorn==0.24.0->-r requirements.txt (line 2)) (8.3.1)
Requirement already satisfied: h11>=0.8 in /home/ids/.local/lib/python3.11/site-packages (from uvicorn==0.24.0->-r requirements.txt (line 2)) (0.16.0)
Requirement already satisfied: python-dateutil>=2.8.2 in /home/ids/.local/lib/python3.11/site-packages (from pandas==2.1.3->-r requirements.txt (line 3)) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /home/ids/.local/lib/python3.11/site-packages (from pandas==2.1.3->-r requirements.txt (line 3)) (2025.2)
Requirement already satisfied: tzdata>=2022.1 in /home/ids/.local/lib/python3.11/site-packages (from pandas==2.1.3->-r requirements.txt (line 3)) (2025.2)
Requirement already satisfied: scipy>=1.5.0 in /home/ids/.local/lib/python3.11/site-packages (from scikit-learn==1.3.2->-r requirements.txt (line 5)) (1.16.3)
Requirement already satisfied: joblib>=1.1.1 in /home/ids/.local/lib/python3.11/site-packages (from scikit-learn==1.3.2->-r requirements.txt (line 5)) (1.5.2)
Requirement already satisfied: threadpoolctl>=2.0.0 in /home/ids/.local/lib/python3.11/site-packages (from scikit-learn==1.3.2->-r requirements.txt (line 5)) (3.6.0)
Requirement already satisfied: annotated-types>=0.4.0 in /home/ids/.local/lib/python3.11/site-packages (from pydantic==2.5.0->-r requirements.txt (line 8)) (0.7.0)
Requirement already satisfied: pydantic-core==2.14.1 in /home/ids/.local/lib/python3.11/site-packages (from pydantic==2.5.0->-r requirements.txt (line 8)) (2.14.1)
Requirement already satisfied: certifi in /home/ids/.local/lib/python3.11/site-packages (from httpx==0.25.1->-r requirements.txt (line 9)) (2025.11.12)
Requirement already satisfied: httpcore in /home/ids/.local/lib/python3.11/site-packages (from httpx==0.25.1->-r requirements.txt (line 9)) (1.0.9)
Requirement already satisfied: idna in /home/ids/.local/lib/python3.11/site-packages (from httpx==0.25.1->-r requirements.txt (line 9)) (3.11)
Requirement already satisfied: sniffio in /home/ids/.local/lib/python3.11/site-packages (from httpx==0.25.1->-r requirements.txt (line 9)) (1.3.1)
Requirement already satisfied: six>=1.5 in /home/ids/.local/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas==2.1.3->-r requirements.txt (line 3)) (1.17.0)
✅ Dipendenze Python aggiornate

 Restart servizi...
✅ Servizi riavviati

╔═══════════════════════════════════════════════╗
║   ✅ AGGIORNAMENTO COMPLETATO                 ║
╚═══════════════════════════════════════════════╝

 VERIFICA SISTEMA:
   • Log backend:  tail -f /var/log/ids/backend.log
   • Log frontend: tail -f /var/log/ids/frontend.log
   • API backend:  curl http://localhost:8000/health
   • Frontend:     curl http://localhost:5000

📊 STATO SERVIZI:
ids         5038  0.3  2.0 1894024 331912 ?      Sl   09:20   0:46 /usr/bin/python3.11 main.py

[root@ids ids]# sudo -u ids /opt/ids/deployment/restart_all.sh
[root@ids ids]# curl http://localhost:5000
curl: (7) Failed to connect to localhost port 5000: Connection refused
[root@ids ids]# curl http://localhost:8000/health
{"status":"healttail -f /var/log/ids/backend.logodel":"loaded","timestamp":"2025-11-21T15:30:17.826004"}[root@ids ids]# tail -f /var/log/ids/backend.log
INFO:     Waiting for application startup.
INFO:     Application startup complete.
ERROR:    [Errno 98] error while attempting to bind on address ('0.0.0.0', 8000): address already in use
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
[LOAD] Modello caricato da models
🚀 Starting IDS API on http://0.0.0.0:8000
📚 Docs available at http://0.0.0.0:8000/docs
INFO:     127.0.0.1:53374 - "GET /stats HTTP/1.1" 200 OK
INFO:     127.0.0.1:59428 - "GET /health HTTP/1.1" 200 OK
^C
[root@ids ids]# tail -f /var/log/ids/frontend.log
        ^


Error: DATABASE_URL must be set. Did you forget to provision a database?
    at <anonymous> (/opt/ids/server/db.ts:9:9)
    at ModuleJob.run (node:internal/modules/esm/module_job:325:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:606:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v20.19.5
^C