diff --git a/docs/misc/autopause-autostop/autopause.md b/docs/misc/autopause-autostop/autopause.md index f1d38c41..bd426bed 100644 --- a/docs/misc/autopause-autostop/autopause.md +++ b/docs/misc/autopause-autostop/autopause.md @@ -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. diff --git a/docs/misc/autopause-autostop/autostop.md b/docs/misc/autopause-autostop/autostop.md index 630c8a54..bbb043c8 100644 --- a/docs/misc/autopause-autostop/autostop.md +++ b/docs/misc/autopause-autostop/autostop.md @@ -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: diff --git a/files/auto/autopause-daemon.sh b/files/auto/autopause-daemon.sh index be884038..e10bf184 100644 --- a/files/auto/autopause-daemon.sh +++ b/files/auto/autopause-daemon.sh @@ -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" diff --git a/files/auto/autostop-daemon.sh b/files/auto/autostop-daemon.sh index 5b9aa0c4..b166e729 100644 --- a/files/auto/autostop-daemon.sh +++ b/files/auto/autostop-daemon.sh @@ -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"