[Unit]
Description=Veza Backend API Service
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/veza/backend-api
# Use wrapper script to ensure environment variables are loaded
ExecStart=/opt/veza/backend-api/start-backend-api.sh
Restart=always
RestartSec=5
# Use journald instead of file redirection to avoid broken pipe issues
StandardOutput=journal
StandardError=journal
StandardInput=null
SyslogIdentifier=veza-backend-api

# Environment variables - CRITICAL: Must be loaded (also loaded by wrapper script)
EnvironmentFile=/etc/veza/backend-api.env

# Ensure log directory exists (for application logs, not systemd logs)
ExecStartPre=/bin/mkdir -p /var/log/veza

# Security
NoNewPrivileges=true
PrivateTmp=true

# Resource limits
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
