[Unit]
Description=AZAION autopilot — onboard mission executor
Documentation=https://github.com/azaion/autopilot
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
User=autopilot
Group=autopilot

ExecStartPre=/bin/sh -c 'mkdir -p /run/azaion && touch /run/azaion/in-flight'
ExecStart=/usr/local/bin/autopilot
ExecStopPost=/bin/rm -f /run/azaion/in-flight

EnvironmentFile=-/etc/azaion/autopilot/secrets.env
Environment=AUTOPILOT_CONFIG=/etc/azaion/autopilot/config.toml
Environment=RUST_LOG=info
Environment=AUTOPILOT_HEALTH_BIND=127.0.0.1:8080

# Bounded restart (per containerization.md §3).
Restart=on-failure
RestartSec=2s
StartLimitBurst=5

# Resource limits — on-airframe memory budget leaves room for the Tier-1 YOLO
# container (~2 GB) and other airframe services on the 8 GB Jetson.
MemoryMax=6G
LimitNOFILE=65536
LimitNPROC=4096

# Hardening
NoNewPrivileges=true
ProtectSystem=full
ProtectHome=true
PrivateTmp=true
ReadWritePaths=/var/lib/autopilot /run/azaion

[Install]
WantedBy=multi-user.target
