itzg / docker-minecraft-server

Docker image that provides a Minecraft Server that will automatically download selected version at startup
https://docker-minecraft-server.readthedocs.io/
Apache License 2.0
9.36k stars 1.54k forks source link

Partially-downloaded server jar's are not handled well at the moment, preventing container start #2841

Open potomato opened 4 months ago

potomato commented 4 months ago

Hi,

I've had a couple of cases recently where I've had to start and then quickly stop a new minecraft server container. The scripts have correctly started downloading the latest jar but the container was stopped before it had finished. On restarting the container I get Error: Invalid or corrupt jarfile minecraft_server.1.20.6.jar or similar, unsurprisingly.

I would make sense to me to first download into a temporary file with a modified name, then rename. On every start we could delete any partially-downloaded files matching the temporary pattern, and then continue to re-download if required.

I'm happy to do this work (I submitted a PR for the bedrock image a while back).

Would this be better to be done as part of your mc-image-helper get in that repo or in this one, perhaps in start-utils.sh?

Thanks for all your effort on this.

Container logs

[init] Setting initial memory to 1G and max to 1G
[init] Starting the Minecraft server...
Error: Invalid or corrupt jarfile minecraft_server.1.20.6.jar
itzg commented 4 months ago

That's a really small window of failure; however, it's obviously not zero since you hit it 😄

You're right that if the mc-image-helper get operation were to download to a temp file and then move into the final location, then that would help close some of those failure windows. As for making the change there or start-utils then it is certainly viable either way, but seems slightly cleaner to enhance mc-image-helper.

So, if you're wanting to help out there, then that would be great. All I ask is that you make very small changes and feel free to send a draft PR with any initial changes you want to consider.

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 30 days with no activity. Please add a comment describing the reason to keep this issue open.