[Unit]
Description=HVAC Know It All Content Aggregator for %i
After=network.target

[Service]
Type=oneshot
# Use the instance name as the user
User=%i
Group=%i
WorkingDirectory=/opt/hvac-kia-content
Environment="PATH=/usr/local/bin:/usr/bin:/bin"

# Load environment variables
EnvironmentFile=/opt/hvac-kia-content/.env

# Python path
Environment="PYTHONPATH=/opt/hvac-kia-content"

# Run the aggregator
ExecStart=/usr/bin/env python3 /opt/hvac-kia-content/run_production.py --job regular

# Restart on failure
Restart=on-failure
RestartSec=60

# Resource limits
MemoryLimit=1G
CPUQuota=80%

# Logging
StandardOutput=append:/var/log/hvac-content/aggregator.log
StandardError=append:/var/log/hvac-content/aggregator-error.log

[Install]
WantedBy=multi-user.target