[Unit]
Description=Provisioning Control Center Web UI
Documentation=https://github.com/provisioning/docs/control-center
Requires=docker.service provisioning-orchestrator.service
After=docker.service provisioning-orchestrator.service network-online.target
Wants=network-online.target

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

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

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

# Restart policy
Restart=always
RestartSec=10s

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

# Timeouts
TimeoutStartSec=120s
TimeoutStopSec=60s

# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=provisioning-control-center

# Resource limits
CPUQuota=100%
MemoryLimit=1G

[Install]
WantedBy=multi-user.target
