Skip to content

Commit

Permalink
Simplify startup and dependencies (#165)
Browse files Browse the repository at this point in the history
Currently there is a whole dependency forest just to start a couple of
startup scripts in order.
Additionally all the services also have a dependency on all the startup
scripts.
This is unnecessary complex, simplify it:

Move startup scripts to /etc/s6-overlay/startup.d
Create oneshot service named "startup" which executes all files in
/etc/s6-overlay/startup.d in alphabetical order
Remove various oneshot scripts from longrun service dependencies
Add "startup" oneshot service to longrun service dependencies

The oneshot service to start all scripts in /etc/s6-overlay/startup.d
could be included in the baseimage after some testing and if that's
something sdr-enthusiasts is interested in.
The script was tested against an empty or non-existent directory as well
and just exits 0 in that case.
If one of started scripts exits with an error, it will announce it and
propagate the error.
This preserves the behaviour of the container startup being aborted in
that case.
  • Loading branch information
wiedehopf authored Mar 18, 2024
1 parent 2b8a017 commit beff68b
Show file tree
Hide file tree
Showing 138 changed files with 27 additions and 29 deletions.
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

COPY rootfs/ /
# only copy files necessary for the build, copy whole rootfs later
# this improves build caching when changing service and startup scripting
COPY rootfs/tar1090-install.sh /
COPY rootfs/etc/nginx.tar1090 /etc/nginx.tar1090

# add telegraf binary
##telegraf##COPY --from=telegraf /usr/bin/telegraf /usr/bin/telegraf
Expand Down Expand Up @@ -178,6 +181,8 @@ RUN set -x && \
popd && \
rm -rf /tmp/*

COPY rootfs/ /

EXPOSE 80/tcp

# Add healthcheck
Expand Down
2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/01-sanity-check/up

This file was deleted.

1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/02-tar1090-update/type

This file was deleted.

2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/02-tar1090-update/up

This file was deleted.

1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/04-tar1090-configure/type

This file was deleted.

2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/04-tar1090-configure/up

This file was deleted.

1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/06-range-outline/type

This file was deleted.

2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/06-range-outline/up

This file was deleted.

1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/07-ngnix-logging/type

This file was deleted.

2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/07-ngnix-logging/up

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/08-graphs1090/down

This file was deleted.

1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/08-graphs1090/type

This file was deleted.

2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/08-graphs1090/up

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/09-rtlsdr-biastee/down

This file was deleted.

1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/09-rtlsdr-biastee/type

This file was deleted.

2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/09-rtlsdr-biastee/up

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 0 additions & 1 deletion rootfs/etc/s6-overlay/s6-rc.d/10-telegraf-conf/type

This file was deleted.

2 changes: 0 additions & 2 deletions rootfs/etc/s6-overlay/s6-rc.d/10-telegraf-conf/up

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/startup/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/startup
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion rootfs/etc/s6-overlay/scripts/readsb
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@ if chk_enabled "$PROMETHEUS_ENABLE"; then
fi

# shellcheck disable=SC2086
"${s6wrap[@]}" "${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS
exec "${s6wrap[@]}" "${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS
18 changes: 18 additions & 0 deletions rootfs/etc/s6-overlay/scripts/startup
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/command/with-contenv bash
# shellcheck shell=bash disable=SC1091,SC2076

source /scripts/common

SDIR=/etc/s6-overlay/startup.d

# exit 0 for nonexistent or empty directory
if ! [[ -d "$SDIR" ]] || [[ -z "$(ls "$SDIR")" ]]; then
exit 0
fi

for NAME in "$SDIR"/*; do
if ! s6wrap --quiet --prepend="$NAME" --timestamps --args "$NAME"; then
s6wrap --quiet --prepend=startup --timestamps --args echo Error running "$NAME"
exit 1
fi
done

0 comments on commit beff68b

Please sign in to comment.