    Found existing installation: joblib 1.5.2
    Uninstalling joblib-1.5.2:
      Successfully uninstalled joblib-1.5.2
Successfully installed joblib-1.3.2
✅ Dipendenze Python installate
 Impostazione permessi...

 Verifica installazione:
✅ FastAPI: 0.104.1
✅ Uvicorn: 0.24.0
✅ Scikit-learn: 1.3.2
✅ Pandas: 2.1.3
✅ HTTPX: 0.25.1
✅ Joblib: 1.3.2

╔═══════════════════════════════════════════════╗
║   ✅ DIPENDENZE PYTHON INSTALLATE             ║
╚═══════════════════════════════════════════════╝

 NOTA:
   Il virtual environment è in: /opt/ids/python_ml/venv
   I systemd services useranno automaticamente questo venv

[root@ids ids]# sudo systemctl restart ids-ml-backend
[root@ids ids]# sudo 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: activating (auto-restart) (Result: exit-code) since Sat 2025-11-22 11:00:28 CET; 5s ago
    Process: 16204 ExecStart=/opt/ids/python_ml/venv/bin/python3 main.py (code=exited, status=1/FAILURE)
   Main PID: 16204 (code=exited, status=1/FAILURE)
        CPU: 3.933s
[root@ids ids]# sudo 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: activating (auto-restart) (Result: exit-code) since Sat 2025-11-22 11:00:28 CET; 7s ago
    Process: 16204 ExecStart=/opt/ids/python_ml/venv/bin/python3 main.py (code=exited, status=1/FAILURE)
   Main PID: 16204 (code=exited, status=1/FAILURE)
        CPU: 3.933s
[root@ids ids]# tail -30 /var/log/ids/ml_backend.log
    from fastapi import FastAPI, HTTPException, BackgroundTasks, Security, Header
ModuleNotFoundError: No module named 'fastapi'
Traceback (most recent call last):
  File "/opt/ids/python_ml/main.py", line 12, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Traceback (most recent call last):
  File "/opt/ids/python_ml/main.py", line 20, in <module>
    from ml_analyzer import MLAnalyzer
  File "/opt/ids/python_ml/ml_analyzer.py", line 8, in <module>
    from sklearn.ensemble import IsolationForest
ModuleNotFoundError: No module named 'sklearn'
INFO:     Started server process [16144]
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:     Started server process [16204]
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
[root@ids ids]# sudo 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 Sat 2025-11-22 11:01:03 CET; 1s ago
   Main PID: 16291 (python3)
      Tasks: 15 (limit: 100409)
     Memory: 100.2M (max: 2.0G available: 1.9G)
        CPU: 3.101s
     CGroup: /system.slice/ids-ml-backend.service
             └─16291 /opt/ids/python_ml/venv/bin/python3 main.py

Nov 22 11:01:03 ids.alfacom.it systemd[1]: Started IDS ML Backend (FastAPI).
[root@ids ids]# sudo 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: activating (auto-restart) (Result: exit-code) since Sat 2025-11-22 11:01:05 CET; 9s ago
    Process: 16291 ExecStart=/opt/ids/python_ml/venv/bin/python3 main.py (code=exited, status=1/FAILURE)
   Main PID: 16291 (code=exited, status=1/FAILURE)
        CPU: 3.804s
[root@ids ids]# sudo 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: activating (auto-restart) (Result: exit-code) since Sat 2025-11-22 11:01:17 CET; 251ms ago
    Process: 16321 ExecStart=/opt/ids/python_ml/venv/bin/python3 main.py (code=exited, status=1/FAILURE)
   Main PID: 16321 (code=exited, status=1/FAILURE)
        CPU: 3.840s
[root@ids ids]# tail -30 /var/log/ids/ml_backend.log
[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:     Started server process [16257]
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:     Started server process [16291]
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:     Started server process [16321]
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
[root@ids ids]# sudo 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 Sat 2025-11-22 11:01:27 CET; 2s ago
   Main PID: 16348 (python3)
      Tasks: 19 (limit: 100409)
     Memory: 118.4M (max: 2.0G available: 1.8G)
        CPU: 3.872s
     CGroup: /system.slice/ids-ml-backend.service
             └─16348 /opt/ids/python_ml/venv/bin/python3 main.py

Nov 22 11:01:27 ids.alfacom.it systemd[1]: Started IDS ML Backend (FastAPI).
[root@ids ids]# sudo 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: activating (auto-restart) (Result: exit-code) since Sat 2025-11-22 11:01:30 CET; 4s ago
    Process: 16348 ExecStart=/opt/ids/python_ml/venv/bin/python3 main.py (code=exited, status=1/FAILURE)
   Main PID: 16348 (code=exited, status=1/FAILURE)
        CPU: 3.911s

Nov 22 11:01:30 ids.alfacom.it systemd[1]: ids-ml-backend.service: Failed with result 'exit-code'.
Nov 22 11:01:30 ids.alfacom.it systemd[1]: ids-ml-backend.service: Consumed 3.911s CPU time.
[root@ids ids]# tail -30 /var/log/ids/ml_backend.log
[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:     Started server process [16291]
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:     Started server process [16321]
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:     Started server process [16348]
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