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

add LOGLEVEL implementation

This commit is contained in:
kx1t 2023-03-27 11:39:27 -04:00
parent 15287ec115
commit 17fe4b2678
4 changed files with 40 additions and 7 deletions

View file

@ -115,6 +115,7 @@ The following parameters must be set (mandatory) for the container to function:
| `READSB_RANGE_OUTLINE_HOURS` | Change which past timeframe the range outline is based on | `--range-outline-hours` | `24` | | `READSB_RANGE_OUTLINE_HOURS` | Change which past timeframe the range outline is based on | `--range-outline-hours` | `24` |
| `READSB_EXTRA_ARGS` | Optional, allows to specify extra parameters for readsb | | Unset | | `READSB_EXTRA_ARGS` | Optional, allows to specify extra parameters for readsb | | Unset |
| `S6_SERVICES_GRACETIME` | Optional, set to 30000 when saving traces / globe_history | | `3000` | | `S6_SERVICES_GRACETIME` | Optional, set to 30000 when saving traces / globe_history | | `3000` |
| `LOGLEVEL` | `verbose` (all messages), `error` (errors only), `none` (minimal) | | `verbose` |
`READSB_EXTRA_ARGS` just passes arguments to the commandline, you can check this file for more options for wiedehofp's readsb fork: <https://github.com/wiedehopf/readsb/blob/dev/help.h> `READSB_EXTRA_ARGS` just passes arguments to the commandline, you can check this file for more options for wiedehofp's readsb fork: <https://github.com/wiedehopf/readsb/blob/dev/help.h>

View file

@ -83,7 +83,6 @@ do
MLAT_PARAM+=(--alt "${READSB_ALT}") MLAT_PARAM+=(--alt "${READSB_ALT}")
fi fi
# [[ -n "${UUID}" ]] && MLAT_PARAM+=(--user "${UUID}") || MLAT_PARAM+=(--user "${MLAT_USER}")
[[ -n "${MLAT_USER}" ]] && MLAT_PARAM+=(--user "${MLAT_USER}") || MLAT_PARAM+=(--user "${UUID}") [[ -n "${MLAT_USER}" ]] && MLAT_PARAM+=(--user "${MLAT_USER}") || MLAT_PARAM+=(--user "${UUID}")
[[ -n "${params[2]}" ]] && MLAT_PARAM+=("--results beast,listen,${params[2]}") || true [[ -n "${params[2]}" ]] && MLAT_PARAM+=("--results beast,listen,${params[2]}") || true
[[ -n "${params[3]}" ]] && MLAT_PARAM+=("${params[3]}") || true [[ -n "${params[3]}" ]] && MLAT_PARAM+=("${params[3]}") || true
@ -93,7 +92,15 @@ do
# run this Mlat_client instance in the background: # run this Mlat_client instance in the background:
echo "[$(date)][${APPNAME}] starting: ${MLAT_CMD} ${MLAT_PARAM[*]}" echo "[$(date)][${APPNAME}] starting: ${MLAT_CMD} ${MLAT_PARAM[*]}"
{ exec ${execstring} 2>&1 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}'; } &
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}'; } &
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}'; } &
elif [[ "${LOGLEVEL,,}" == "none" ]]; then
{ exec ${execstring} >/dev/null 2>/dev/null; } &
fi
pid_array[$!]="${MLAT_PARAM[*]}" pid_array[$!]="${MLAT_PARAM[*]}"
sleep 5 sleep 5
done done
@ -107,10 +114,18 @@ do
then then
# it exited - let's restart: # it exited - let's restart:
sleep "${RESTARTTIMER}" sleep "${RESTARTTIMER}"
echo "[$(date)][${APPNAME}] MLAT_Client $(awk '{print $6}' <<< "${pid_array[$mlat_pid]}") exited. Attempting to restart." [[ "$LOGLEVEL,," != "none" ]] && echo "[$(date)][${APPNAME}] 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)"
{ exec ${execstring} 2>&1 1>/dev/null | stdbuf -o0 awk -v app="${APPNAME}" -v inst="$(awk '{split($6,x,":"); print x[1]}' <<< "${pid_array[$mlat_pid]}")" '{print "[" strftime("%Y/%m/%d %H:%M:%S", systime()) "][" app "][" inst "] " $0}'; } &
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}'; } &
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}'; } &
elif [[ "${LOGLEVEL,,}" == "none" ]]; then
{ exec ${execstring} >/dev/null 2>/dev/null; } &
fi
pid_array[$!]="${pid_array[${mlat_pid}]}" pid_array[$!]="${pid_array[${mlat_pid}]}"
unset "pid_array[${mlat_pid}]" unset "pid_array[${mlat_pid}]"
fi fi

View file

@ -113,6 +113,13 @@ fi
echo "[$(date)][mlathub] Starting MLATHUB..." echo "[$(date)][mlathub] Starting MLATHUB..."
# shellcheck disable=SC2086 # shellcheck disable=SC2086
"${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS 2>&1 | \ if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
"${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS 2>&1 | \
mawk -W Interactive '{print "[" strftime("%Y/%m/%d %H:%M:%S", systime()) "][mlathub] " $0}' mawk -W Interactive '{print "[" strftime("%Y/%m/%d %H:%M:%S", systime()) "][mlathub] " $0}'
elif [[ "${LOGLEVEL,,}" == "error" ]]; then
"${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
"${MLATHUB_BIN}" "${MLATHUB_CMD[@]}" $MLATHUB_EXTRA_ARGS >/dev/null 2>/dev/null
fi

View file

@ -315,6 +315,16 @@ if [[ -n "$READSB_BEAST_BAUDRATE" ]]; then
fi fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
"${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS 2>&1 | \ if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then
mawk -W Interactive '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][readsb] " $0}' "${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
"${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
"${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS >/dev/null 2>/dev/null
fi