mirror of
https://github.com/sdr-enthusiasts/docker-adsb-ultrafeeder.git
synced 2024-11-25 15:20:10 +00:00
homogenize date format in container logs
This commit is contained in:
parent
8eb96adc74
commit
b497d8fe01
1 changed files with 13 additions and 13 deletions
|
@ -18,7 +18,7 @@
|
||||||
#---------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
APPNAME="mlat-client"
|
APPNAME="mlat-client"
|
||||||
echo "[$(date)][${APPNAME}] Started as an s6 service"
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] 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)][${APPNAME}] Warning: MLAT_CONFIG not defined - MLAT will be disabled."
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] 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)][${APPNAME}] ERROR: either UUID or MLAT_USER must be defined - MLAT will be disabled."
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] 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)][${APPNAME}] ERROR: READSB_LAT or LAT must be defined - MLAT will be disabled."
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] 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)][${APPNAME}] ERROR: READSB_LON or LONG must be defined - MLAT will be disabled."
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] 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)][${APPNAME}] ERROR: READSB_ALT or ALT must be defined - MLAT will be disabled."
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] 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)][${APPNAME}] ERROR -- MLAT_CONFIG is malformed: \"${instance}\". Stopping MLAT execution."
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] 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)][${APPNAME}] WARNING: MLAT_USER is not set - using random number \"${rnd}\" as MLAT_USER"
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] 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)][$APPNAME] Delaying start of MLAT client(s) until container is established..."
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][$APPNAME] 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,7 +165,7 @@ 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)][${APPNAME}] starting: ${MLAT_CMD} ${MLAT_PARAM[*]}"
|
echo "[$(date +"%Y-%m-%d %H:%M:%S")][${APPNAME}] starting: ${MLAT_CMD} ${MLAT_PARAM[*]}"
|
||||||
|
|
||||||
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 ${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}'; } &
|
||||||
|
@ -194,14 +194,14 @@ do
|
||||||
then
|
then
|
||||||
# it exited - let's restart:
|
# it exited - let's restart:
|
||||||
sleep "${RESTARTTIMER}"
|
sleep "${RESTARTTIMER}"
|
||||||
[[ "${LOGLEVEL,,}" != "none" ]] && echo "[$(date)][${APPNAME}] MLAT_Client $(awk '{print $6}' <<< "${pid_array[$mlat_pid]}") exited. Attempting to restart." || true
|
[[ "${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
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
execstring="$(echo ${MLAT_CMD} ${pid_array[$mlat_pid]} | xargs)"
|
execstring="$(echo ${MLAT_CMD} ${pid_array[$mlat_pid]} | xargs)"
|
||||||
|
|
||||||
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 ${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
|
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 ${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
|
elif [[ "${LOGLEVEL,,}" == "none" ]]; then
|
||||||
{ exec ${execstring} >/dev/null 2>/dev/null; } &
|
{ exec ${execstring} >/dev/null 2>/dev/null; } &
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue