From 221359c9801a1fb7e0e400dc732a161e9e6dadf8 Mon Sep 17 00:00:00 2001 From: kx1t Date: Sun, 9 Apr 2023 10:41:07 -0400 Subject: [PATCH] delay start of MLAT Hub until all MLAT clients are up --- rootfs/etc/cont-finish.d/03-remove-mlathub-up | 25 +++++++++++++++++++ rootfs/etc/cont-init.d/60-mlathub-prep | 25 +++++++++++++++++++ rootfs/etc/services.d/mlat-client/run | 3 +++ rootfs/etc/services.d/mlathub/run | 4 +-- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 rootfs/etc/cont-finish.d/03-remove-mlathub-up create mode 100644 rootfs/etc/cont-init.d/60-mlathub-prep diff --git a/rootfs/etc/cont-finish.d/03-remove-mlathub-up b/rootfs/etc/cont-finish.d/03-remove-mlathub-up new file mode 100644 index 0000000..9608275 --- /dev/null +++ b/rootfs/etc/cont-finish.d/03-remove-mlathub-up @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bash +#shellcheck shell=bash disable=SC2015,SC1091 + +source /scripts/common + +# Remove MLATHub Up +#--------------------------------------------------------------------------------------------- +# Copyright (C) 2023, Ramon F. Kolb (kx1t) +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program. +# If not, see . +#--------------------------------------------------------------------------------------------- + +rm -f /run/mlathub_up + +exit 0 \ No newline at end of file diff --git a/rootfs/etc/cont-init.d/60-mlathub-prep b/rootfs/etc/cont-init.d/60-mlathub-prep new file mode 100644 index 0000000..ca5bfbb --- /dev/null +++ b/rootfs/etc/cont-init.d/60-mlathub-prep @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bash +#shellcheck shell=bash disable=SC2015,SC1091 + +source /scripts/common + +# MLATHub Prep +#--------------------------------------------------------------------------------------------- +# Copyright (C) 2023, Ramon F. Kolb (kx1t) +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program. +# If not, see . +#--------------------------------------------------------------------------------------------- + +rm -f /run/mlathub_up + +exit 0 \ No newline at end of file diff --git a/rootfs/etc/services.d/mlat-client/run b/rootfs/etc/services.d/mlat-client/run index ec4b0ca..7644e9a 100644 --- a/rootfs/etc/services.d/mlat-client/run +++ b/rootfs/etc/services.d/mlat-client/run @@ -131,6 +131,9 @@ sleep 10 # sleep a bit so everything is well established - starting readsb m sleep 5 done +# All MLAT Clients are up, so set the flag: +touch /run/mlathub_up + # Now iterate over all MLAT-client instances and check if they are still running: while true do diff --git a/rootfs/etc/services.d/mlathub/run b/rootfs/etc/services.d/mlathub/run index e76a344..73e97ac 100644 --- a/rootfs/etc/services.d/mlathub/run +++ b/rootfs/etc/services.d/mlathub/run @@ -99,10 +99,10 @@ fi # Handle "--net-heartbeat=" MLATHUB_CMD+=("--net-heartbeat=${READSB_NET_HEARTBEAT:-30}") -if ! pgrep readsb >/dev/null || ! pgrep 'mlat-client' >/dev/null +if [[ ! -f /run/mlathub_up ]] then echo "[$(date)][mlathub] Delaying MLAT hub start until container is established..." - while ! pgrep readsb >/dev/null || ! pgrep 'mlat-client' >/dev/null + while [[ ! -f /run/mlathub_up ]] do sleep 2 done