ids.alfacom.it/attached_assets/Pasted-systemctl-stop-ids-ml-backend-root-ids-systemctl-start-_1771243202583.txt
marco370 3e0bd64b14 Fix ML backend startup issues and improve logging
Address issues with the ML backend not starting correctly due to missing dependencies by ensuring the correct virtual environment is used and improving logging for easier debugging of startup failures.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 0a2e2f05-ffc8-4767-ba4d-9b4f2b98416d
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/MmMtYN7
2026-02-16 12:00:21 +00:00

59 lines
2.0 KiB
Plaintext

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'