diff --git a/context/run-server b/context/run-server index 487ddf9..419b926 100755 --- a/context/run-server +++ b/context/run-server @@ -1,14 +1,17 @@ #!/bin/sh -export TERM=xterm-256color -cd /spigot +cleanup() { + rcon -m -p 25575 --host localhost --password "${MC_RCON_PASSWORD}" say Warning! Server is shutting down in 5 seconds... + sleep 5 + rcon -m -p 25575 --host localhost --password "${MC_RCON_PASSWORD}" stop +} + cd /server envsubst < /spigot/server.properties.in > /server/server.properties [ "$ACCEPT_EULA" = "true" ] && echo eula=true > /server/eula.txt -java -Xmx6G -jar /spigot/spigot-VERSION.jar nogui & -JAVA_PID=$! -trap "rcon -m -p 25575 --host localhost --password '${MC_RCON_PASSWORD}' stop" INT +java -Xmx${SERVER_MEMORY:-6G} -jar /spigot/spigot-VERSION.jar nogui & +trap "cleanup" INT -wait -wait +# wait twice in the event sigint (docker stop) is received +wait; wait diff --git a/docker-compose.example.yaml b/docker-compose.example.yaml index 96b6e69..ea2cf8c 100644 --- a/docker-compose.example.yaml +++ b/docker-compose.example.yaml @@ -13,7 +13,10 @@ services: ports: - 25565:25565 environment: + # Entrypoint variables - "ACCEPT_EULA=false" + - "SERVER_MEMORY=6G" + # server.properties Values - "MC_ACCEPTS_TRANSFERS=false" - "MC_ALLOW_FLIGHT=false" - "MC_ALLOW_NETHER=true"