1
0
Fork 0
mirror of https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git synced 2024-11-22 13:50:14 +00:00

implement use of s6wrap

This commit is contained in:
kx1t 2023-05-03 15:58:08 -04:00
parent 172d1dde64
commit 7a5f9f182c
5 changed files with 57 additions and 37 deletions

View file

@ -93,7 +93,29 @@ services:
- INFLUXDBV2_URL=${INFLUX_URL} - INFLUXDBV2_URL=${INFLUX_URL}
- INFLUXDBV2_TOKEN=${INFLUX_TOKEN} - INFLUXDBV2_TOKEN=${INFLUX_TOKEN}
- INFLUXDBV2_BUCKET=${INFLUX_BUCKET} - INFLUXDBV2_BUCKET=${INFLUX_BUCKET}
- PROMETHEUS_ENABLE=true - PROMETHEUS_ENABLE=true - VRS_ENHANCED_LAYERS_CONFIG='
{
/* Map Options */
"defaultMap" : 1,
"layerMenuPosition" : "bottomleft",
/* Enable Layers */
"airspace" : 0,
"navAids" : 0,
"reportingPoints" : 0,
"tfrUSA" : 0,
"seaMarkers" : 0,
"trainMap" : 0,
"clouds" : 0,
"rain" : 0,
"temps" : 0,
"wind" : 0,
"pressure" : 0,
"dayNight" : 0,
"civilAirfields" : 0,
"militaryAirfields" : 0,
"heliports" : 0,
"glidingSpots" : 0
}''
volumes: volumes:
- /opt/adsb/ultrafeeder/globe_history:/var/globe_history - /opt/adsb/ultrafeeder/globe_history:/var/globe_history
- /opt/adsb/ultrafeeder/graphs1090:/var/lib/collectd - /opt/adsb/ultrafeeder/graphs1090:/var/lib/collectd

View file

@ -20,4 +20,4 @@ source /scripts/common
# If not, see <https://www.gnu.org/licenses/>. # If not, see <https://www.gnu.org/licenses/>.
#--------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------
[[ -f /.CONTAINER_VERSION ]] && echo "[$(date)][INIT] Container Version: $(cat /.CONTAINER_VERSION), build date $(stat -c '%y' /.CONTAINER_VERSION |sed 's|\(.*\)\.[0-9]* \(.*\)|\1 \2|g')" || true [[ -f /.CONTAINER_VERSION ]] && s6wrap --prepend=01-print-container-version --timestamps --args echo "Container Version: $(cat /.CONTAINER_VERSION), build date $(stat -c '%y' /.CONTAINER_VERSION |sed 's|\(.*\)\.[0-9]* \(.*\)|\1 \2|g')" || true

View file

@ -18,7 +18,7 @@
#--------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------
APPNAME="mlat-client" APPNAME="mlat-client"
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] Started as an s6 service" s6wrap --prepend="${APPNAME}" --timestamps --args echo "Started as an s6 service"
source /scripts/common source /scripts/common
source /scripts/interpret_ultrafeeder_config source /scripts/interpret_ultrafeeder_config
@ -30,27 +30,27 @@ declare -A pid_array
if [[ -z "${MLAT_CONFIG}" ]] if [[ -z "${MLAT_CONFIG}" ]]
then then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] Warning: MLAT_CONFIG not defined - MLAT will be disabled." s6wrap --prepend="${APPNAME}" --timestamps --args echo "Warning: MLAT_CONFIG not defined - MLAT will be disabled."
sleep infinity sleep infinity
fi fi
if [[ -z "${MLAT_USER}" ]] && [[ -z "${UUID}" ]] if [[ -z "${MLAT_USER}" ]] && [[ -z "${UUID}" ]]
then then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] ERROR: either UUID or MLAT_USER must be defined - MLAT will be disabled." s6wrap --prepend="${APPNAME}" --timestamps --args echo "ERROR: either UUID or MLAT_USER must be defined - MLAT will be disabled."
sleep infinity sleep infinity
fi fi
if [[ -z "$LAT$READSB_LAT" ]]; then if [[ -z "$LAT$READSB_LAT" ]]; then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] ERROR: READSB_LAT or LAT must be defined - MLAT will be disabled." s6wrap --prepend="${APPNAME}" --timestamps --args echo "ERROR: READSB_LAT or LAT must be defined - MLAT will be disabled."
sleep infinity sleep infinity
fi fi
if [[ -z "$LONG$READSB_LON" ]]; then if [[ -z "$LONG$READSB_LON" ]]; then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] ERROR: READSB_LON or LONG must be defined - MLAT will be disabled." s6wrap --prepend="${APPNAME}" --timestamps --args echo "ERROR: READSB_LON or LONG must be defined - MLAT will be disabled."
sleep infinity sleep infinity
fi fi
if [[ -z "$ALT$READSB_ALT" ]]; then if [[ -z "$ALT$READSB_ALT" ]]; then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] ERROR: READSB_ALT or ALT must be defined - MLAT will be disabled." s6wrap --prepend="${APPNAME}" --timestamps --args echo "ERROR: READSB_ALT or ALT must be defined - MLAT will be disabled."
sleep infinity sleep infinity
fi fi
@ -80,7 +80,7 @@ do
# Check if the params array has values for the mandatory elements: # Check if the params array has values for the mandatory elements:
if [[ -z "${params[0]}" ]] || [[ -z "${params[1]}" ]] if [[ -z "${params[0]}" ]] || [[ -z "${params[1]}" ]]
then then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] ERROR -- MLAT_CONFIG is malformed: \"${instance}\". Stopping MLAT execution." s6wrap --prepend="${APPNAME}" --timestamps --args echo "ERROR -- MLAT_CONFIG is malformed: \"${instance}\". Stopping MLAT execution."
# shellcheck disable=SC2046 # shellcheck disable=SC2046
kill $(ps -s $$ -o pid=) kill $(ps -s $$ -o pid=)
sleep infinity sleep infinity
@ -114,7 +114,7 @@ do
MLAT_PARAM+=(--user "${MLAT_USER}") MLAT_PARAM+=(--user "${MLAT_USER}")
else else
rnd="${RANDOM}" rnd="${RANDOM}"
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] WARNING: MLAT_USER is not set - using random number \"${rnd}\" as MLAT_USER" s6wrap --prepend="${APPNAME}" --timestamps --args echo "WARNING: MLAT_USER is not set - using random number \"${rnd}\" as MLAT_USER"
MLAT_PARAM+=(--user "${rnd}") MLAT_PARAM+=(--user "${rnd}")
fi fi
@ -156,7 +156,7 @@ do
# ------------------------------------------------ # ------------------------------------------------
# Ready to launch, but wait until readsb is established... # Ready to launch, but wait until readsb is established...
if ! pgrep readsb >/dev/null; then if ! pgrep readsb >/dev/null; then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][$APPNAME] Delaying start of MLAT client(s) until container is established..." s6wrap --prepend="${APPNAME}" --timestamps --args echo "Delaying start of MLAT client(s) until container is established..."
while ! pgrep readsb >/dev/null while ! pgrep readsb >/dev/null
do do
sleep 2 sleep 2
@ -165,12 +165,13 @@ do
sleep 10 # sleep a bit so everything is well established - starting readsb may take a bit sleep 10 # sleep a bit so everything is well established - starting readsb may take a bit
# run this Mlat_client instance in the background: # run this Mlat_client instance in the background:
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] starting: ${MLAT_CMD} ${MLAT_PARAM[*]}" s6wrap --prepend="${APPNAME}" --timestamps --args echo "starting: ${MLAT_CMD} ${MLAT_PARAM[*]}"
#shellcheck disable=SC2069,SC2086
if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
{ exec ${execstring} 2>&1 | stdbuf -o0 awk -v app="${APPNAME}" -v inst="${params[0]}" '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][" app "][" inst "] " $0}'; } & { exec s6wrap --prepend="${APPNAME}" --timestamps --args ${execstring}; } &
elif [[ "${LOGLEVEL,,}" == "error" ]]; then elif [[ "${LOGLEVEL,,}" == "error" ]]; then
{ exec ${execstring} 2>&1 >/dev/null | stdbuf -o0 awk -v app="${APPNAME}" -v inst="${params[0]}" '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][" app "][" inst "] " $0}'; } & { exec s6wrap --prepend="${APPNAME}" --timestamps --args ${execstring} 2>&1 >/dev/null; } &
elif [[ "${LOGLEVEL,,}" == "none" ]]; then elif [[ "${LOGLEVEL,,}" == "none" ]]; then
{ exec ${execstring} >/dev/null 2>/dev/null; } & { exec ${execstring} >/dev/null 2>/dev/null; } &
fi fi
@ -194,14 +195,15 @@ do
then then
# it exited - let's restart: # it exited - let's restart:
sleep "${RESTARTTIMER}" sleep "${RESTARTTIMER}"
[[ "${LOGLEVEL,,}" != "none" ]] && echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] MLAT_Client $(awk '{print $6}' <<< "${pid_array[$mlat_pid]}") exited. Attempting to restart." || true [[ "${LOGLEVEL,,}" != "none" ]] && s6wrap --prepend="${APPNAME}" --timestamps --args echo "MLAT_Client $(awk '{print $6}' <<< "${pid_array[$mlat_pid]}") exited. Attempting to restart." || true
# shellcheck disable=SC2086 # shellcheck disable=SC2086
execstring="$(echo ${MLAT_CMD} ${pid_array[$mlat_pid]} | xargs)" execstring="$(echo ${MLAT_CMD} ${pid_array[$mlat_pid]} | xargs)"
#shellcheck disable=SC2069,SC2086
if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
{ exec ${execstring} 2>&1 | stdbuf -o0 awk -v app="${APPNAME}" -v inst="${params[0]}" '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][" app "][" inst "] " $0}'; } & { exec s6wrap --prepend="${APPNAME}" --timestamps --args ${execstring} 2>&1; } &
elif [[ "${LOGLEVEL,,}" == "error" ]]; then elif [[ "${LOGLEVEL,,}" == "error" ]]; then
{ exec ${execstring} 2>&1 >/dev/null | stdbuf -o0 awk -v app="${APPNAME}" -v inst="${params[0]}" '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][" app "][" inst "] " $0}'; } & { exec s6wrap --prepend="${APPNAME}" --timestamps --args ${execstring} 2>&1 >/dev/null; } &
elif [[ "${LOGLEVEL,,}" == "none" ]]; then elif [[ "${LOGLEVEL,,}" == "none" ]]; then
{ exec ${execstring} >/dev/null 2>/dev/null; } & { exec ${execstring} >/dev/null 2>/dev/null; } &
fi fi

View file

@ -6,12 +6,12 @@ source /scripts/common
source /scripts/interpret_ultrafeeder_config source /scripts/interpret_ultrafeeder_config
if [[ -z "${MLAT_CONFIG}" ]] && [[ -z "$MLATHUB_NET_CONNECTOR" ]]; then if [[ -z "${MLAT_CONFIG}" ]] && [[ -z "$MLATHUB_NET_CONNECTOR" ]]; then
echo "[$(date "+%Y-%m-%d %H:%M:%S")][${APPNAME}] No MLAT servers have been defined in MLAT_CONFIG and no external sources have been defined in MLATHUB_NET_CONNECTOR - no need to start MLATHUB" s6wrap --prepend="${APPNAME}" --timestamps --args echo "No MLAT servers have been defined in MLAT_CONFIG and no external sources have been defined in MLATHUB_NET_CONNECTOR - no need to start MLATHUB"
sleep infinity sleep infinity
fi fi
if chk_enabled "${MLATHUB_DISABLED}"; then if chk_enabled "${MLATHUB_DISABLED}"; then
echo "[$(date "+%Y-%m-%d %H:%M:%S")][${APPNAME}] MLATHUB is disabled." s6wrap --prepend="${APPNAME}" --timestamps --args echo "MLATHUB is disabled."
sleep infinity sleep infinity
fi fi
@ -59,7 +59,7 @@ done
if (( mlat_result_sources == 0 )) if (( mlat_result_sources == 0 ))
then then
echo "[$(date "+%Y-%m-%d %H:%M:%S")][${APPNAME}] No MLAT servers have been defined in MLAT_CONFIG - no need to start MLATHUB" s6wrap --prepend="${APPNAME}" --timestamps --args echo "No MLAT servers have been defined in MLAT_CONFIG - no need to start MLATHUB"
sleep infinity sleep infinity
fi fi
@ -109,7 +109,7 @@ MLATHUB_CMD+=("--net-heartbeat=${READSB_NET_HEARTBEAT:-35}")
if [[ ! -f /run/mlathub_up ]] if [[ ! -f /run/mlathub_up ]]
then then
echo "[$(date "+%Y-%m-%d %H:%M:%S")][${APPNAME}] Delaying MLAT hub start until container is established..." s6wrap --prepend="${APPNAME}" --timestamps --args echo "Delaying MLAT hub start until container is established..."
while [[ ! -f /run/mlathub_up ]] while [[ ! -f /run/mlathub_up ]]
do do
sleep 2 sleep 2
@ -117,18 +117,16 @@ then
fi fi
sleep 5 # sleep a bit so everything is well established sleep 5 # sleep a bit so everything is well established
echo "[$(date "+%Y-%m-%d %H:%M:%S")][${APPNAME}] Starting MLATHUB..." s6wrap --prepend="${APPNAME}" --timestamps --args echo "Starting MLATHUB..."
# shellcheck disable=SC2086 # shellcheck disable=SC2086,SC2069
if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
"${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS 2>&1 | \ s6wrap --prepend="${APPNAME}" --timestamps --args "${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS 2>&1
mawk -W Interactive '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][mlathub] " $0}'
elif [[ "${LOGLEVEL,,}" == "error" ]]; then elif [[ "${LOGLEVEL,,}" == "error" ]]; then
"${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS 2>&1 >/dev/null | \ s6wrap --prepend="${APPNAME}" --timestamps --args "${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS 2>&1 >/dev/null
mawk -W Interactive '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][mlathub] " $0}'
elif [[ "${LOGLEVEL,,}" == "none" ]]; then elif [[ "${LOGLEVEL,,}" == "none" ]]; then
"${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS >/dev/null 2>/dev/null s6wrap --prepend="${APPNAME}" --timestamps --args "${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS >/dev/null 2>/dev/null
fi fi
echo "[$(date "+%Y-%m-%d %H:%M:%S")][${APPNAME}] The mlathub instance has exited. Restarting in 10 seconds." s6wrap --prepend="${APPNAME}" --timestamps --args echo "WARNING: The mlathub instance has exited. Restarting in 10 seconds."
sleep 10 sleep 10

View file

@ -64,12 +64,12 @@ if ! chk_enabled "$READSB_NET_SBS_DISABLE_REDUCE"; then
fi fi
if chk_enabled "${READSB_FORWARD_MLAT}"; then if chk_enabled "${READSB_FORWARD_MLAT}"; then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] WARNING -- READSB_FORWARD_MLAT has been set! Do not feed the output of this container to any aggregators!" s6wrap --prepend="${APPNAME}" --timestamps --args echo "WARNING -- READSB_FORWARD_MLAT has been set! Do not feed the output of this container to any aggregators!"
READSB_CMD+=("--forward-mlat") READSB_CMD+=("--forward-mlat")
fi fi
if chk_enabled "${READSB_FORWARD_MLAT_SBS}"; then if chk_enabled "${READSB_FORWARD_MLAT_SBS}"; then
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] WARNING -- READSB_FORWARD_MLAT_SBS has been set! Do not feed the SBS (BaseStation) output of this container to any aggregators!" s6wrap --prepend="${APPNAME}" --timestamps --args echo "WARNING -- READSB_FORWARD_MLAT_SBS has been set! Do not feed the SBS (BaseStation) output of this container to any aggregators!"
READSB_CMD+=("--forward-mlat-sbs") READSB_CMD+=("--forward-mlat-sbs")
fi fi
@ -319,18 +319,16 @@ if chk_enabled "$PROMETHEUS_ENABLE"; then
READSB_CMD+=("--write-prom=/run/readsb-prometheus.prom") READSB_CMD+=("--write-prom=/run/readsb-prometheus.prom")
fi fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086,SC2069
if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
"${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS 2>&1 | \ s6wrap --prepend="${APPNAME}" --timestamps --args "${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS 2>&1
mawk -W Interactive '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][readsb] " $0}'
elif [[ "${LOGLEVEL,,}" == "error" ]]; then elif [[ "${LOGLEVEL,,}" == "error" ]]; then
"${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS 2>&1 1>/dev/null | \ s6wrap --prepend="${APPNAME}" --timestamps --args "${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS 2>&1 1>/dev/null
mawk -W Interactive '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][readsb] " $0}'
elif [[ "${LOGLEVEL,,}" == "none" ]]; then elif [[ "${LOGLEVEL,,}" == "none" ]]; then
"${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS >/dev/null 2>/dev/null "${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS >/dev/null 2>/dev/null
fi fi
echo "[$(date "+%Y-%m-%d %H:%M:%S")][${APPNAME}] The main readsb instance has exited. Restarting in 10 seconds." s6wrap --prepend="${APPNAME}" --timestamps --args echo "WARNING: The main readsb instance has exited. Restarting in 10 seconds."
sleep 10 sleep 10