A simple systemd unit file

I wrote my first systemd unit file today. It’s a thing that runs code to import stats from Starlink’s GRPC into InfluxDB using this Python code. Nothing remarkable about this but it’s the first time I’ve ever used systemd like this.

[Unit]
Description=Starlink GRPC monitor
After=influxdb.service
StartLimitIntervalSec=5
StartLimitBurst=5

[Service]
User=nelson
ExecStart=/usr/local/src/starlink-grpc-tools/collect.sh
Restart=always

[Install]
WantedBy=multi-user.target

OK, the remarkable thing is Restart=always. I was having trouble with the script crashing after running a long time. OTOH it turns out it was crashing because Starlink’s protocol changed and the code had to be updated; no number of restarts would fix that. That’s what those StartLimits are for; if it fails to start 5 times in 5 seconds then systemd gives up trying.

Also I’m naughty and run this as myself, not some dedicated system user.