[Unit]
Description=Provisioning Orchestrator Service
Documentation=https://github.com/provisioning/docs/orchestrator
Requires=docker.service
After=docker.service network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/opt/provisioning/platform
EnvironmentFile=-/opt/provisioning/platform/.env

# Start orchestrator container
ExecStart=/usr/bin/docker start -a provisioning-orchestrator

# Stop orchestrator container
ExecStop=/usr/bin/docker stop -t 30 provisioning-orchestrator

# Restart policy
Restart=always
RestartSec=10s

# Health checks
ExecStartPost=/bin/sh -c 'for i in $(seq 1 30); do if curl -f http://localhost:8080/health; then exit 0; fi; sleep 1; done; exit 1'

# Timeouts
TimeoutStartSec=120s
TimeoutStopSec=60s

# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=provisioning-orchestrator

# Resource limits
CPUQuota=200%
MemoryLimit=2G
TasksMax=4096

[Install]
WantedBy=multi-user.target
