commit 679ac4b782f3328a726c79b446edccd77cb9cece
Author: Adrian Reber <adrian(a)lisas.de>
Date: Sun Jan 16 18:05:06 2022 +0100
Automatically restart mirrorlist-server process if down
Signed-off-by: Adrian Reber <adrian(a)lisas.de>
.../files/restart-mirrorlist-containers | 31 +++++++++----------
1 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/roles/mirrormanager/mirrorlist-server/files/restart-mirrorlist-containers
b/roles/mirrormanager/mirrorlist-server/files/restart-mirrorlist-containers
index 06760ef..d20c340 100644
--- a/roles/mirrormanager/mirrorlist-server/files/restart-mirrorlist-containers
+++ b/roles/mirrormanager/mirrorlist-server/files/restart-mirrorlist-containers
@@ -8,6 +8,17 @@ TIME_DRAIN=30
TIME_RESTART=5
TIME_DISABLE=5
+check_and_restart() {
+ systemctl start $1
+ if [[ ${?} -ne 0 ]]; then
+ systemctl start $1
+ if [[ ${?} -ne 0 ]]; then
+ echo "Unable to start $1"
+ exit 1
+ fi
+ fi
+}
+
if [ ! -f /srv/mirrorlist/data/mirrorlist2/global_netblocks.txt ];
then
cp /srv/mirrorlist/data/mirrorlist1/* /srv/mirrorlist/data/mirrorlist2/
@@ -16,8 +27,8 @@ fi
## check mirrorlist1 running
if [ `systemctl show mirrorlist1 -p ActiveState` != 'ActiveState=active' ]; then
# mirrorlist1 not running, there is a problem
- echo "Error: mirrorlist1 is not running as expected"
- exit 1
+ echo "Error: mirrorlist1 is not running as expected. Trying to restart"
+ check_and_restart mirrorlist1
fi
## check mirrorlist2 running
@@ -50,15 +61,7 @@ sleep ${TIME_DISABLE}
# restart mirrorlist1 (new protbuf cache and make sure it's processing ok)
systemctl stop mirrorlist1
sleep 1
-systemctl start mirrorlist1
-if [[ ${?} -ne 0 ]]; then
- systemctl start mirrorlist1
- if [[ ${?} -ne 0 ]]; then
- echo "Unable to start mirrorlist1"
- exit 1
- fi
-fi
-
+check_and_restart mirrorlist1
sleep ${TIME_RESTART}
curl -q -H
mirrors.rpmfusion.org ${mirrorlist1} -s -f --retry 50 --retry-delay 10
--retry-connrefused --retry-max-time 180 | grep "sha512" >/dev/null
@@ -81,11 +84,7 @@ sleep ${TIME_DISABLE}
# restart mirrorlist2
systemctl stop mirrorlist2
sleep 1
-systemctl start mirrorlist2
-if [[ ${?} -ne 0 ]]; then
- echo "Unable to start mirrorlist2"
- exit 1
-fi
+check_and_restart mirrorlist2
sleep ${TIME_RESTART}
curl -q -H
mirrors.rpmfusion.org ${mirrorlist2} -o/dev/null -s -f --retry 50
--retry-delay 10 --retry-connrefused --retry-max-time 180