mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-10-19 09:28:11 +00:00
Autopause functionality (#531)
This commit is contained in:
1 parent
ede58d9159
commit
71a7afab17
13 files changed
+324
-10
No files matched your search
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]] ; then
|
||||
# save world
|
||||
rcon-cli save-all >/dev/null
|
||||
|
||||
# wait until mc-monitor is no longer connected to the server
|
||||
while :
|
||||
do
|
||||
if [[ -z "$(netstat -nt | grep "127.0.0.1:$SERVER_PORT" | grep 'ESTABLISHED')" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# finally pause the process
|
||||
echo "[$(date -Iseconds)] [Autopause] Pausing Java process" >/tmp/terminal-mc
|
||||
killall -q -STOP java
|
||||
fi
|
||||
Reference in new issue
Block a user