mirror of
https://github.com/itzg/docker-minecraft-server
synced 2024-12-12 13:22:28 +00:00
Allow skipping autopause/autostop using a file (#2261)
This commit is contained in:
parent
ce65bcc840
commit
4a942dbc02
4 changed files with 32 additions and 2 deletions
|
@ -14,6 +14,8 @@ The utility used to wake the server (`knock(d)`) works at network interface leve
|
|||
|
||||
A file called `.paused` is created in `/data` directory when the server is paused and removed when the server is resumed. Other services may check for this file's existence before waking the server.
|
||||
|
||||
A `.skip-pause` file can be created in the `/data` directory to make the server skip autopausing, for as long as the file is present. The autopause timer will also be reset.
|
||||
|
||||
A starting, example compose file has been provided in [examples/docker-compose-autopause.yml](https://github.com/itzg/docker-minecraft-server/blob/master/examples/docker-compose-autopause.yml).
|
||||
|
||||
Auto-pause is not compatible with `EXEC_DIRECTLY=true` and the two cannot be set together.
|
||||
|
|
|
@ -6,6 +6,8 @@ An option to stop the server after a specified time has been added for niche app
|
|||
|
||||
the docker container variables have to be set accordingly (restart policy set to "no") and that the container has to be manually restarted.
|
||||
|
||||
A `.skip-stop` file can be created in the `/data` directory to make the server skip autostopping, for as long as the file is present. The autostop timer will also be reset.
|
||||
|
||||
A starting, example compose file has been provided in [examples/docker-compose-autostop.yml](https://github.com/itzg/docker-minecraft-server/blob/master/examples/docker-compose-autostop.yml).
|
||||
|
||||
Enable the Autostop functionality by setting:
|
||||
|
|
|
@ -62,7 +62,13 @@ do
|
|||
# Server startup
|
||||
if mc_server_listening ; then
|
||||
TIME_THRESH=$(($(current_uptime)+$AUTOPAUSE_TIMEOUT_INIT))
|
||||
logAutopause "MC Server listening for connections - pausing in $AUTOPAUSE_TIMEOUT_INIT seconds"
|
||||
|
||||
if [ -e /data/.skip-pause ] ; then
|
||||
logAutopause "'/data/.skip-pause' file is present - skipping pausing"
|
||||
else
|
||||
logAutopause "MC Server listening for connections - pausing in $AUTOPAUSE_TIMEOUT_INIT seconds"
|
||||
fi
|
||||
|
||||
STATE=K
|
||||
fi
|
||||
;;
|
||||
|
@ -71,6 +77,9 @@ do
|
|||
if java_clients_connected ; then
|
||||
logAutopause "Client connected - waiting for disconnect"
|
||||
STATE=E
|
||||
elif [ -e /data/.skip-pause ] ; then
|
||||
logAutopause "'/data/.skip-pause' file is present - skipping pausing"
|
||||
STATE=E
|
||||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutopause "No client connected since startup / knocked - pausing"
|
||||
|
@ -92,6 +101,10 @@ do
|
|||
if java_clients_connected ; then
|
||||
logAutopause "Client reconnected - waiting for disconnect"
|
||||
STATE=E
|
||||
elif [ -e /data/.skip-pause ] ; then
|
||||
TIME_THRESH=$(($(current_uptime)+$AUTOPAUSE_TIMEOUT_EST))
|
||||
logAutopause "'/data/.skip-pause' file is present - skipping pausing"
|
||||
STATE=E
|
||||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutopause "No client reconnected - pausing"
|
||||
|
|
|
@ -28,7 +28,13 @@ do
|
|||
# Server startup
|
||||
if mc_server_listening ; then
|
||||
TIME_THRESH=$(($(current_uptime)+AUTOSTOP_TIMEOUT_INIT))
|
||||
logAutostop "MC Server listening for connections - stopping in $AUTOSTOP_TIMEOUT_INIT seconds"
|
||||
|
||||
if [ -e /data/.skip-stop ] ; then
|
||||
logAutostop "'/data/.skip-stop' file is present - skipping stopping"
|
||||
else
|
||||
logAutostop "MC Server listening for connections - stopping in $AUTOSTOP_TIMEOUT_INIT seconds"
|
||||
fi
|
||||
|
||||
STATE=II
|
||||
fi
|
||||
;;
|
||||
|
@ -37,6 +43,9 @@ do
|
|||
if java_clients_connected ; then
|
||||
logAutostop "Client connected - waiting for disconnect"
|
||||
STATE=E
|
||||
elif [ -e /data/.skip-stop ] ; then
|
||||
logAutostop "'/data/.skip-stop' file is present - skipping stopping"
|
||||
STATE=E
|
||||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutostop "No client connected since startup - stopping server"
|
||||
|
@ -58,6 +67,10 @@ do
|
|||
if java_clients_connected ; then
|
||||
logAutostop "Client reconnected - waiting for disconnect"
|
||||
STATE=E
|
||||
elif [ -e /data/.skip-stop ] ; then
|
||||
TIME_THRESH=$(($(current_uptime)+$AUTOSTOP_TIMEOUT_EST))
|
||||
logAutostop "'/data/.skip-stop' file is present - skipping stopping"
|
||||
STATE=E
|
||||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutostop "No client reconnected - stopping"
|
||||
|
|
Loading…
Reference in a new issue