[Unit]
Description=AGIBOT X2 web dashboard (serves http://<robot-ip>:8770)
After=network-online.target
Wants=network-online.target

[Service]
# A one-shot launcher: run_dashboard.sh starts the ROS bridge and the web
# dashboard if they are not already up, then returns. It is idempotent, so the
# timer below re-runs it every minute as a crash-and-restart watchdog.
#
# Type=oneshot WITHOUT RemainAfterExit: the unit goes back to "inactive" after
# each run, which is what lets the timer's OnUnitActiveSec fire again. With
# RemainAfterExit=yes the unit stays "active" forever and the timer never
# re-triggers (NextElapse=infinity).
Type=oneshot
WorkingDirectory=/home/agi/x2_dashboard
ExecStart=/home/agi/x2_dashboard_agent/run_dashboard.sh
TimeoutStartSec=120
# The launcher setsid's the agent and dashboard into their own sessions so they
# outlive this one-shot. KillMode=none stops systemd from reaping them when the
# unit deactivates, and lets the unit return to "inactive" cleanly - which is
# what re-arms the watchdog timer (OnUnitActiveSec). Without this the cgroup
# stays populated, the unit stays "active" forever, and NextElapse=infinity.
KillMode=none

[Install]
WantedBy=default.target
