diff --git a/rootfs/etc/cont-finish.d/02-remove-prometheus-data b/rootfs/etc/cont-finish.d/02-remove-prometheus-data new file mode 100644 index 0000000..3def684 --- /dev/null +++ b/rootfs/etc/cont-finish.d/02-remove-prometheus-data @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash +#shellcheck shell=bash + +rm -f /run/readsb-prometheus.prom || true diff --git a/rootfs/etc/services.d/prometheus-readsb/run b/rootfs/etc/services.d/prometheus-readsb/run new file mode 100644 index 0000000..6e0a5b7 --- /dev/null +++ b/rootfs/etc/services.d/prometheus-readsb/run @@ -0,0 +1,12 @@ +#!/usr/bin/with-contenv bash +#shellcheck shell=bash + +if [[ -n "$PROMETHEUS_ENABLE" ]]; then + while [[ ! -f /run/readsb-prometheus.prom ]] + do + sleep 1 + done + echo -e "HTTP/1.1 200 OK\nContent-Type: text/plain\n\n$(cat /run/readsb-prometheus.prom)" | ncat -l 9274 > /dev/null 2>&1 +else + sleep infinity +fi diff --git a/rootfs/etc/services.d/readsb/run b/rootfs/etc/services.d/readsb/run index a30cf06..07398f8 100644 --- a/rootfs/etc/services.d/readsb/run +++ b/rootfs/etc/services.d/readsb/run @@ -314,6 +314,14 @@ if [[ -n "$READSB_BEAST_BAUDRATE" ]]; then READSB_CMD+=("--beast-baudrate=$READSB_BEAST_BAUDRATE") fi +##################### +# Handle --write-prom= + +if [[ -n "$PROMETHEUS_ENABLE" ]]; then + READSB_CMD+=("--write-prom=/run/readsb-prometheus.prom") +fi + + # shellcheck disable=SC2086 if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then "${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS 2>&1 | \