systemctl stop ids-ml-backend
[root@ids ~]# systemctl start ids-ml-backend
[root@ids ~]# systemctl status ids-ml-backend
● ids-ml-backend.service - IDS ML Backend (FastAPI)
     Loaded: loaded (/etc/systemd/system/ids-ml-backend.service; enabled; preset: disabled)
     Active: active (running) since Mon 2026-02-16 12:59:19 CET; 4s ago
   Main PID: 3600 (python3)
      Tasks: 26 (limit: 100409)
     Memory: 157.6M (max: 2.0G available: 1.8G)
        CPU: 3.936s
     CGroup: /system.slice/ids-ml-backend.service
             └─3600 /opt/ids/python_ml/venv/bin/python3 main.py

Feb 16 12:59:19 ids.alfacom.it systemd[1]: Started IDS ML Backend (FastAPI).
[root@ids ~]# cat /etc/systemd/system/ids-ml-backend.service
[Unit]
Description=IDS ML Backend (FastAPI)
After=network.target postgresql-16.service
Wants=postgresql-16.service

[Service]
Type=simple
User=ids
Group=ids
WorkingDirectory=/opt/ids/python_ml
EnvironmentFile=/opt/ids/.env

# Comando esecuzione (usa virtual environment)
ExecStart=/opt/ids/python_ml/venv/bin/python3 main.py

# Restart automatico sempre (non solo on-failure)
Restart=always
RestartSec=10
StartLimitInterval=300
StartLimitBurst=5

# Limiti risorse
LimitNOFILE=65536
MemoryMax=2G

# Logging
StandardOutput=append:/var/log/ids/ml_backend.log
StandardError=append:/var/log/ids/ml_backend.log
SyslogIdentifier=ids-ml-backend

[Install]
WantedBy=multi-user.target
[root@ids ~]# tail -f /var/log/ids/backend.log
🚀 Starting IDS API on http://0.0.0.0:8000
📚 Docs available at http://0.0.0.0:8000/docs
[Mon Feb 16 12:56:12 CET 2026] Backend Python NON attivo, riavvio...
[Mon Feb 16 12:56:14 CET 2026] Backend riavviato con PID: 3453
Traceback (most recent call last):
  File "/opt/ids/python_ml/main.py", line 21, in <module>
    from ml_hybrid_detector import MLHybridDetector
  File "/opt/ids/python_ml/ml_hybrid_detector.py", line 13, in <module>
    from xgboost import XGBClassifier
ModuleNotFoundError: No module named 'xgboost'
                                                           