Make starter restart correctly on pi's
This configures systemd much better so it automatically restarts and
gets the kill signals right.
Change-Id: I43576758f1b137ca24ad1ee960dd8715143aa7e6
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/starter/starter.sh b/aos/starter/starter.sh
index 2c8494e..2db812a 100755
--- a/aos/starter/starter.sh
+++ b/aos/starter/starter.sh
@@ -8,8 +8,9 @@
ln -s /var/local/natinst/log/FRC_UserProgram.log /tmp/FRC_UserProgram.log
ln -s /var/local/natinst/log/FRC_UserProgram.log "${ROBOT_CODE}/FRC_UserProgram.log"
elif [[ "$(hostname)" == "pi-"* ]]; then
- ROBOT_CODE="/home/pi/robot_code"
-
+ # We have systemd configured to handle restarting, so just exec.
+ export PATH="${PATH}:/home/pi/robot_code"
+ exec starterd
else
ROBOT_CODE="${HOME}/robot_code"
fi
diff --git a/y2020/vision/rootfs/frc971.service b/y2020/vision/rootfs/frc971.service
index bf42652..e7b8d7c 100644
--- a/y2020/vision/rootfs/frc971.service
+++ b/y2020/vision/rootfs/frc971.service
@@ -2,8 +2,16 @@
Description=Start up 971 robot code
[Service]
-Type=oneshot
-ExecStart=su pi -c /home/pi/robot_code/starter.sh
+User=pi
+Group=pi
+Type=simple
+WorkingDirectory=/home/pi/robot_code
+ExecStart=/home/pi/robot_code/starter.sh
+KillMode=mixed
+TimeoutStopSec=10
+
+Restart=always
+RestartSec=5s
[Install]
WantedBy=multi-user.target