Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some optimizations #44

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN set -x && \
curl \
--location \
--output /tmp/airspy_adsb-linux-arm64.tgz \
"https://github.com/wiedehopf/airspy-conf/raw/master/buster/airspy_adsb-linux-arm64.tgz" \
"https://github.com/wiedehopf/airspy-conf/raw/master/bookworm/airspy_adsb-linux-arm64.tgz" \
&& \
tar \
xvf /tmp/airspy_adsb-linux-arm64.tgz \
Expand Down
19 changes: 9 additions & 10 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 @@ -143,7 +142,7 @@ if [[ -z "$AIRSPY_ADSB_ARCH" ]]; then

else
"${s6wrap[@]}" echo "ERROR: Unsupported architecture: $(uname -m)!"
exec sleep infinity
stop_service
fi
fi

Expand All @@ -153,25 +152,25 @@ AIRSPY_ADSB_BIN="/usr/local/bin/airspy_adsb.${AIRSPY_ADSB_ARCH}"
# Ensure binary exists
if [[ ! -x "$AIRSPY_ADSB_BIN" ]]; then
"${s6wrap[@]}" echo "ERROR: Executable binary not found for architecture: $AIRSPY_ADSB_ARCH!"
exec sleep infinity
stop_service
fi

# Ensure binary runnable
if ! "$AIRSPY_ADSB_BIN" -h > /dev/null 2>&1; then
"${s6wrap[@]}" echo "ERROR: Executable $AIRSPY_ADSB_ARCH binary not supported on $(uname -m) architecture!"
exec sleep infinity
stop_service
fi

# Execute binary with arguments prepared above
"${s6wrap[@]}" echo "Running $AIRSPY_ADSB_ARCH binary on $(uname -m) architecture."
"${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[@]}"
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/scripts/nginx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
source /scripts/common

if ! chk_enabled "${AIRSPY_ADSB_STATS}"; then
exec sleep infinity
stop_service
fi

exec s6wrap --quiet --prepend=nginx --timestamps --args /usr/sbin/nginx