From 2fc45d66502a1e044dc56896493f975240c907e6 Mon Sep 17 00:00:00 2001 From: Kyle Stang <33678573+kylestang@users.noreply.github.com> Date: Thu, 17 Nov 2022 06:45:15 -0800 Subject: [PATCH] Add .paused file when server is paused (#1830) --- README.md | 2 ++ files/auto/pause.sh | 3 +++ files/auto/resume.sh | 3 +++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 95a6ae08..3c15c604 100644 --- a/README.md +++ b/README.md @@ -1720,6 +1720,8 @@ On startup the `server.properties` file is checked and, if applicable, a warning The utility used to wake the server (`knock(d)`) works at network interface level. So the correct interface has to be set using the `AUTOPAUSE_KNOCK_INTERFACE` variable when using non-default networking environments (e.g. host-networking, Portainer oder NAS solutions). See the description of the variable below. +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 starting, example compose file has been provided in [examples/docker-compose-autopause.yml](examples/docker-compose-autopause.yml). ### Enabling Autopause diff --git a/files/auto/pause.sh b/files/auto/pause.sh index 19e6a436..c7462e52 100644 --- a/files/auto/pause.sh +++ b/files/auto/pause.sh @@ -21,4 +21,7 @@ if [[ $( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]] ; t # finally pause the process logAutopauseAction "Pausing Java process" pkill -STOP java + + # create .paused file in data directory + touch /data/.paused fi diff --git a/files/auto/resume.sh b/files/auto/resume.sh index af55da95..19a4fa62 100644 --- a/files/auto/resume.sh +++ b/files/auto/resume.sh @@ -9,4 +9,7 @@ if [[ $( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^T.*$ ]] ; t logAutopauseAction "Knocked from $1, resuming Java process" echo "$1" > /var/log/knocked-source pkill -CONT java + + # remove .paused file from data directory + rm -f /data/.paused fi