Skip to content

Commit

Permalink
Update the autopause server listener to be proxy aware (#2978)
Browse files Browse the repository at this point in the history
  • Loading branch information
paradox460 authored Jul 8, 2024
1 parent b89c698 commit 4232a98
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions files/auto/autopause-fcns.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# shellcheck source=../scripts/start-utils
. "${SCRIPTS:-/}start-utils"
current_uptime() {
awk '{print $1}' /proc/uptime | cut -d . -f 1
}
Expand All @@ -16,14 +18,20 @@ rcon_client_exists() {
[[ -n "$(ps -ax -o comm | grep 'rcon-cli')" ]]
}

use_proxy() {
if isTrue "$USES_PROXY_PROTOCOL"; then
echo "--use-proxy"
fi
}

mc_server_listening() {
mc-monitor status --host "${SERVER_HOST:-localhost}" --port "$SERVER_PORT" --timeout 10s >& /dev/null
mc-monitor status $(use_proxy) --host "${SERVER_HOST:-localhost}" --port "$SERVER_PORT" --timeout 10s >&/dev/null
}

java_clients_connections() {
local connections
if java_running ; then
if ! connections=$(mc-monitor status --host "${SERVER_HOST:-localhost}" --port "$SERVER_PORT" --show-player-count); then
if java_running; then
if ! connections=$(mc-monitor status $(use_proxy) --host "${SERVER_HOST:-localhost}" --port "$SERVER_PORT" --show-player-count); then
# consider it a non-zero player count if the ping fails
# otherwise a laggy server with players connected could get paused
connections=1
Expand Down

0 comments on commit 4232a98

Please sign in to comment.