fix multiarch autopause daemon (#722)

This commit is contained in:
Michael Kirsch
2021-01-12 16:05:12 -06:00
committed by GitHub
parent 02c8393bc6
commit b519c43e16
2 changed files with 28 additions and 10 deletions
+27 -9
View File
@@ -15,17 +15,35 @@ autopause_error_loop() {
logAutopause "Autopause failed to initialize. This log entry will be printed every 30 minutes." logAutopause "Autopause failed to initialize. This log entry will be printed every 30 minutes."
while : while :
do do
if [[ -n $(ps -ax -o comm | grep java) ]] ; then sleep 1800
break logAutopause "Autopause failed to initialize."
fi
sleep 0.1
done done
}
# wait for java process to be started
while :
do
if java_process_exists ; then
break
fi
sleep 0.1
done
# check for interface existence
if [[ -z "$AUTOPAUSE_KNOCK_INTERFACE" ]] ; then
logAutopause "AUTOPAUSE_KNOCK_INTERFACE variable must not be empty!"
autopause_error_loop
fi
if ! [[ -d "/sys/class/net/$AUTOPAUSE_KNOCK_INTERFACE" ]] ; then
logAutopause "Selected interface \"$AUTOPAUSE_KNOCK_INTERFACE\" does not exist!"
autopause_error_loop
fi
sudo /usr/sbin/knockd -c /tmp/knockd-config.cfg -d -i "$AUTOPAUSE_KNOCK_INTERFACE"
if [ $? -ne 0 ] ; then
logAutopause "Failed to start knockd daemon." logAutopause "Failed to start knockd daemon."
logAutopause "Possible cause: docker's host network mode." logAutopause "Probable cause: Unable to attach to interface \"$AUTOPAUSE_KNOCK_INTERFACE\"."
logAutopause "Recreate without host mode or disable autopause functionality." autopause_error_loop
logAutopause "Stopping server."
pkill -SIGTERM java
exit 1
fi fi
STATE=INIT STATE=INIT
+1 -1
View File
@@ -9,7 +9,7 @@ java_running() {
} }
java_process_exists() { java_process_exists() {
[[ -n "$(ps -a -o comm | grep 'java')" ]] [[ -n "$(ps -ax -o comm | grep 'java')" ]]
} }
rcon_client_exists() { rcon_client_exists() {