Skip to content

Commit 4232a98

Browse files
authored
Update the autopause server listener to be proxy aware (#2978)
1 parent b89c698 commit 4232a98

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

files/auto/autopause-fcns.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

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

21+
use_proxy() {
22+
if isTrue "$USES_PROXY_PROTOCOL"; then
23+
echo "--use-proxy"
24+
fi
25+
}
26+
1927
mc_server_listening() {
20-
mc-monitor status --host "${SERVER_HOST:-localhost}" --port "$SERVER_PORT" --timeout 10s >& /dev/null
28+
mc-monitor status $(use_proxy) --host "${SERVER_HOST:-localhost}" --port "$SERVER_PORT" --timeout 10s >&/dev/null
2129
}
2230

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

0 commit comments

Comments
 (0)