[Unit]
Description=IDS ML Backend (FastAPI)
After=network.target postgresql.service
Requires=postgresql.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 in caso di crash
Restart=on-failure
RestartSec=10s

# 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
