feat: use server list ping for versions less than 1.7

#1131
This commit is contained in:
Geoff Bourne 2021-11-24 14:30:20 -06:00
parent 84c577cc96
commit dca29dcbb5
4 changed files with 14 additions and 3 deletions

View File

@ -49,7 +49,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=0.10.1 --var app=mc-monitor --file {{.app}} \ --var version=0.10.3 --var app=mc-monitor --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \

View File

@ -2,6 +2,9 @@
# shellcheck source=../scripts/start-utils # shellcheck source=../scripts/start-utils
. "${SCRIPTS:-/}start-utils" . "${SCRIPTS:-/}start-utils"
if [ -f /data/.mc-health.env ]; then
. /data/.mc-health.env
fi
if isTrue "${DISABLE_HEALTHCHECK}"; then if isTrue "${DISABLE_HEALTHCHECK}"; then
echo "Healthcheck disabled" echo "Healthcheck disabled"
@ -10,6 +13,6 @@ elif isTrue "${ENABLE_AUTOPAUSE}" && [[ "$( ps -ax -o stat,comm | grep 'java' |
echo "Java process suspended by Autopause function" echo "Java process suspended by Autopause function"
exit 0 exit 0
else else
mc-monitor status --host localhost --port "${SERVER_PORT:-25565}" mc-monitor status "${MC_HEALTH_EXTRA_ARGS[@]}" --host localhost --port "${SERVER_PORT:-25565}"
exit $? exit $?
fi fi

View File

@ -92,6 +92,14 @@ if isTrue "${ENABLE_AUTOPAUSE}"; then
${SCRIPTS:-/}start-autopause ${SCRIPTS:-/}start-autopause
fi fi
if versionLessThan 1.7; then
echo "
MC_HEALTH_EXTRA_ARGS=(
--use-server-list-ping
)
" > /data/.mc-health.env
fi
log "Resolving type given ${TYPE}" log "Resolving type given ${TYPE}"
case "${TYPE^^}" in case "${TYPE^^}" in
*BUKKIT|SPIGOT) *BUKKIT|SPIGOT)

View File

@ -67,7 +67,7 @@ variants=(
forge-${mcVersion}-${forgeVersion}-${mcVersion}-universal.jar forge-${mcVersion}-${forgeVersion}-${mcVersion}-universal.jar
fabric-${mcVersion}-${fabricVersion}-server-launch.jar fabric-${mcVersion}-${fabricVersion}-server-launch.jar
) )
for f in ${variants[@]}; do for f in "${variants[@]}"; do
if [ -f $f ]; then if [ -f $f ]; then
export SERVER=$f export SERVER=$f
break break