Skip to content

Commit

Permalink
move to exec
Browse files Browse the repository at this point in the history
this change uses the s6 death tally logic to check if it's the first
start of the service, if it's not it will delay the start of airspy_adsb

in the usual case of a normal container startup, airspy_adsb is
instantly started up with exec which frees some memory used by bash
  • Loading branch information
wiedehopf committed Aug 6, 2024
1 parent 17c2b05 commit 4af84ef
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions rootfs/etc/s6-overlay/scripts/airspy_adsb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#shellcheck shell=bash disable=SC1091

source /scripts/common
trap 'pkill -P $$' SIGTERM SIGINT SIGHUP SIGQUIT

s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args)

Expand Down Expand Up @@ -167,11 +166,11 @@ fi
"${s6wrap[@]}" echo "Running: ${AIRSPY_ADSB_BIN} ${AIRSPY_ADSB_CMD[*]}"

# Slow down restarts
sleep 10 &
# wait 30 seconds if this is not the first startup (this should only happen on crashes or a bad command line, thus this can be a long timeout)
if [[ $(s6-svdt /run/service/airspy_adsb | wc -l) != 0 ]]; then
"${s6wrap[@]}" echo "delaying restart by 30 seconds"
sleep 30
fi

#shellcheck disable=SC2016
"${s6wrap[@]}" "${AIRSPY_ADSB_BIN}" "${AIRSPY_ADSB_CMD[@]}" &

# trap will only work properly while the shell is running / waiting, not while another program is being foreground executed
# the first wait exits due to the signal which is trapped, the 2nd wait actually waits for collectd to exit
wait || wait || true
exec "${s6wrap[@]}" "${AIRSPY_ADSB_BIN}" "${AIRSPY_ADSB_CMD[@]}"

0 comments on commit 4af84ef

Please sign in to comment.