diff --git a/README.md b/README.md index b08e26f..76a00ec 100644 --- a/README.md +++ b/README.md @@ -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_EXTRA_ARGS` | Optional, allows to specify extra parameters for readsb | | Unset | | `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: diff --git a/rootfs/etc/services.d/mlat-client/run b/rootfs/etc/services.d/mlat-client/run index b7a7a8a..7643d37 100644 --- a/rootfs/etc/services.d/mlat-client/run +++ b/rootfs/etc/services.d/mlat-client/run @@ -83,7 +83,6 @@ do MLAT_PARAM+=(--alt "${READSB_ALT}") 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 "${params[2]}" ]] && MLAT_PARAM+=("--results beast,listen,${params[2]}") || true [[ -n "${params[3]}" ]] && MLAT_PARAM+=("${params[3]}") || true @@ -93,7 +92,15 @@ do # run this Mlat_client instance in the background: 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[*]}" sleep 5 done @@ -107,10 +114,18 @@ do then # it exited - let's restart: 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 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}]}" unset "pid_array[${mlat_pid}]" fi diff --git a/rootfs/etc/services.d/mlathub/run b/rootfs/etc/services.d/mlathub/run index e99c675..5d3f1d1 100644 --- a/rootfs/etc/services.d/mlathub/run +++ b/rootfs/etc/services.d/mlathub/run @@ -113,6 +113,13 @@ fi echo "[$(date)][mlathub] Starting MLATHUB..." # 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}' +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 diff --git a/rootfs/etc/services.d/readsb/run b/rootfs/etc/services.d/readsb/run index 65274d3..a30cf06 100644 --- a/rootfs/etc/services.d/readsb/run +++ b/rootfs/etc/services.d/readsb/run @@ -315,6 +315,16 @@ if [[ -n "$READSB_BEAST_BAUDRATE" ]]; then fi # shellcheck disable=SC2086 -"${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS 2>&1 | \ - mawk -W Interactive '{print "[" strftime("%Y-%m-%d %H:%M:%S", systime()) "][readsb] " $0}' +if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then + "${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 + + +