Skip to content

Commit

Permalink
Add SERVER_HOST Environment in mc-monitor command (#2875)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipepasc authored Jun 5, 2024
1 parent 8fd98f0 commit c828985
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/mc-health
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ elif isTrue "${ENABLE_AUTOPAUSE}" && [[ "$( ps -ax -o stat,comm | grep 'java' |
echo "Java process suspended by Autopause function"
exit 0
else
mc-monitor status "${MC_HEALTH_EXTRA_ARGS[@]}" --host localhost --port "${SERVER_PORT:-25565}"
mc-monitor status "${MC_HEALTH_EXTRA_ARGS[@]}" --host "${SERVER_HOST:-localhost}" --port "${SERVER_PORT:-25565}"
exit $?
fi
8 changes: 8 additions & 0 deletions docs/configuration/misc-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ To allow time for players to finish what they're doing during a graceful server

The grace period can be increased using [the -t option on docker-compose down](https://docs.docker.com/compose/reference/down/) or set the [stop_grace_period](https://docs.docker.com/compose/compose-file/05-services/#stop_grace_period) in the compose file.

## Configuration Options for Minecraft Server Health Monitoring

The image tags include specific variables to simplify configuration for monitoring the health of a Minecraft server:

- `-e SERVER_HOST=localhost` : This variable sets the host address of the Minecraft server to be monitored. By default, it is set to `localhost`, but you can replace it with the actual hostname or IP address of your Minecraft server.

- `-e SERVER_PORT=25565` : This variable sets the port number on which the Minecraft server is running. By default, Minecraft servers run on port 25565, but if your server is configured to use a different port, you should replace `25565` with the correct port number. This helps the monitoring system to accurately check the health status of the Minecraft server on the specified port.

## OpenJ9 Specific Options

The openj9 image tags include specific variables to simplify configuration:
Expand Down
4 changes: 2 additions & 2 deletions files/auto/autopause-fcns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ rcon_client_exists() {
}

mc_server_listening() {
mc-monitor status --host localhost --port "$SERVER_PORT" --timeout 10s >& /dev/null
mc-monitor status --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 localhost --port "$SERVER_PORT" --show-player-count); then
if ! connections=$(mc-monitor status --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 c828985

Please sign in to comment.