Skip to content

Instantly share code, notes, and snippets.

@wiedehopf
Last active December 14, 2019 09:34
Show Gist options
  • Save wiedehopf/0f7691e536d5eb67da881a7a7afd46f9 to your computer and use it in GitHub Desktop.
Save wiedehopf/0f7691e536d5eb67da881a7a7afd46f9 to your computer and use it in GitHub Desktop.
readsb template systemd service
# enable start of all instances system startup:
systemctl enable readsb.service
# start/restart all instances:
systemctl restart readsb
# stop all:
systemctl stop readsb
# restart individual:
systemctl stop readsb@3
# /etc/default/readsb
# readsb configuration
# This is sourced by /etc/systemd/system/default.target.wants/readsb.service as
# daemon startup configuration.
RECEIVER_OPTIONS=""
DECODER_OPTIONS=""
NET_OPTIONS="--net-only --net --net-heartbeat 60 --net-ro-size 1300 --net-ro-interval 0.2 --net-ri-port 0 --net-ro-port 0 --net-sbs-port 0 --net-bo-port 0"
JSON_OPTIONS="--json-location-accuracy 2"
# /lib/systemd/system/readsb.service
# readsb service for systemd
# This service is actually a systemd target,
# but we are using a service since targets cannot be reloaded.
[Unit]
Description=readsb instances
Wants=network.target
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/systemctl --no-block start readsb@0.service readsb@1.service readsb@2.service readsb@3.service readsb@4.service readsb@5.service readsb@6.service readsb@7.service
ExecReload=/bin/true
[Install]
WantedBy=default.target
# /lib/systemd/system/readsb@.service
# readsb service for systemd
[Unit]
Description=readsb@%i
PartOf=readsb.service
ReloadPropagatedFrom=readsb.service
[Service]
EnvironmentFile=/etc/default/readsb
SyslogIdentifier=readsb%i
RuntimeDirectory=readsb%i
RuntimeDirectoryMode=0755
ExecStart=/usr/local/bin/readsb \
$RECEIVER_OPTIONS $DECODER_OPTIONS $NET_OPTIONS $JSON_OPTIONS --net-bi-port 2100%i --net-bo-port 430%i5 --net-vrs-port 381%i5\
--write-json /run/readsb%i --quiet
Type=simple
Restart=on-failure
RestartSec=5
RestartPreventExitStatus=64
[Install]
WantedBy=default.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment