Closed rwtallant13 closed 3 years ago
I'll research providing an option there, but it might defeat the graceful shutdown logic that mc-server-runner is handling.
@rwtallant13 can you test out the image itzg/minecraft-server:test-exec-directly
which adds the option for -e EXEC_DIRECTLY=true
?
however I'm concerned that any of the stop signals I tried for docker stop
may not be properly handled by the minecraft server and flushing changes on shutdown like how this issue states https://bugs.mojang.com/browse/MC-202209
It only logs
[16:43:15] [Server thread/INFO]: Stopping server
whereas my mc-server-runner
uses rcon to send a stop
command and the graceful shutdown is very evident:
2021/04/02 16:40:44 Stopping with rcon-cli
[16:40:45] [RCON Listener #1/INFO]: Thread RCON Client /127.0.0.1 started
[16:40:45] [Server thread/INFO]: [Rcon: Stopping the server]
[16:40:45] [Server thread/INFO]: Stopping server
2021-04-02T16:40:45.225Z INFO mc-server-runner Waiting for completion...
[16:40:45] [Server thread/INFO]: Saving players
[16:40:45] [Server thread/INFO]: Saving worlds
[16:40:45] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[16:40:45] [RCON Client /127.0.0.1 #2/INFO]: Thread RCON Client /127.0.0.1 shutting down
[16:40:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[16:40:53] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
[16:40:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[16:40:53] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
[16:40:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[16:40:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[16:40:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[16:40:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[16:40:53] [Server thread/INFO]: Thread RCON Listener stopped
2021-04-02T16:40:53.660Z INFO mc-server-runner Done
So, I highly recommend using your preferred console access (like the plugin you're wanting in the first place) to gracefully stop servers.
I tried to create a test container with this command and attach to it but it seemed the same as before. How would i go about testing this correctly? I'm ready to test and let you know how it works.
docker run -d -it -p 25566:25565 -e TYPE=FABRIC -e EULA=TRUE -e EXEC_DIRECTLY=TRUE itzg/minecraft-server:test-exec-directly
Also will this work with both the forge native console and the fabric mod console that i originally linked?
Using docker attach
is how I would have tested it. If that still doesn't work, then I'm afraid it's a lower level Docker restriction that I can't address.
I didn't test with the console access myself, but approach seemed right.
Looking again at this comment, EXEC_DIRECTLY=true
eliminates the mc-server-runner
mentioned. I also remembered su-exec
is called at the very start
so just in case that's also the problem I pushed another update to that test image and added an option for -e SKIP_SUDO=true
to bypass that.
I spoke too soon. Re-read the comment several times over and noticed the entrypoint statement and found...yes, that actually does show color from the forge startup logs:
So bear with me as a debug more.
It turns out it was the log4j config that was getting in the way. So, I have now made that disabled by default.
Now when I attach I get a proper >
prompt and can press tab to auto-complete:
Wow this is perfect! Works for me in forge and fabric with the mod.
So the skip_sudo flag is not needed correct?
And also is this change going to interfere with the autopause functionality like it would the shutdown functionality?
And just so I'm aware, I shouldn't rely on shutting down/restarting the server with docker anymore with this change correct? and should instead attach through the console and shutdown and/or i can send an rcon command to shutdown?
Excellent!
So the skip_sudo flag is not needed correct?
Correct, but thought I'd leave the option anyway.
And also is this change going to interfere with the autopause functionality like it would the shutdown functionality?
Hmm, I think it shouldn't interfere with autopause since that spawns off a separate process.
And just so I'm aware, I shouldn't rely on shutting down/restarting the server with docker anymore with this change correct? and should instead attach through the console and shutdown and/or i can send an rcon command to shutdown?
Just to be safe, yes use rcon or console to stop
the server.
Awesome. I'll also make sure to keep track of my logs now since I see that's mentioned in the commit. Thanks again!
forge and fabric have interactive shell like consoles that have a history, allow arrow keys and tab completion, but these don't work when attached through docker. Is it possible to get this native console using this?
Theres an open issue regarding this on the fabric mods github. https://github.com/chirs241097/jline4mcdsrv/issues/1
Thanks.