[Unit]
Description=Stable Diffusion REST API Server
After=network.target
Documentation=https://github.com/stable-diffusion-rest

[Service]
Type=simple
User={{USER}}
Group={{USER}}
WorkingDirectory={{INSTALL_DIR}}
ExecStart={{INSTALL_DIR}}/stable-diffusion-rest-server \
    --models-dir {{MODELS_DIR}} \
    --checkpoints checkpoints \
    --host 0.0.0.0 \
    --port 8080 \
    {{LOGGING_OPTIONS}}

# Restart behavior
Restart=on-failure
RestartSec=10s

# Security hardening
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths={{QUEUE_DIR}} {{OUTPUT_DIR}} {{LOG_DIR}}

# Standard output/error configuration
StandardOutput=journal
StandardError=journal
SyslogIdentifier=stable-diffusion-rest

# Resource limits (adjust as needed)
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
