I manage a chef cookbook for deploying minecraft servers. Minecraft currently edits servers.properties, banned-ips.txt, banned-players.txt on each startup. This causes problems for people using configuration management tools to deploy their minecraft server.
The way these tools work generally is if you have changes to your templates, in this case the configuration files named above, the server will restart. If you do not have any changes the server has no reason to restart.
Since minecraft rewrites the files managed (possibly others as well) each startup, my cookbook readjusts the files each time to match the templates I have defined, so every run requires a restart to the server.
Is there a reason why minecraft has to edit these configuration files each startup, adding timestamps and adjusting the order of the settings?
Linked issues
relates to 1
Comments 13
The server makes some "adjustments" to the config files when starting:
Fixing invalid difficulty settings
Fixing the case of usernames in banned, ops and whitelist
But it should be no problem to compare the files regardless of the order of lines.
Hacked some crappy shell script (without having an *IX machine here, so expect that the script contains errors):
checkServerRestart
#!/bin/sh
function UnorderedCompare {
sort < $1 > arg1.tmp
sort < $2 > arg2.tmp
diff arg1.tmp arg2.tmp
exitcode=$?
rm -f arg1.tmp
rm -f arg2.tmp
return $exitcode
}
if [ $(UnorderedCompare server.properties server.properties.template) ]; then
# restart server
fi
if [ $(UnorderedCompare whitelist.txt whitelist.txt.template) ]; then
# restart server
fi
...
This seems to be a bit of a hack. I don't understand why it needs to adjust the config file in the first place. Don't take this the wrong way, but can you name another server that modifies it's configuration on startup? What if apache and nginx started to modify config files on startup? Lets assume the administrators know what they are doing, so we don't have to implement hacks like this.
Chef is writing in ruby and has a certain way of doing things. In this case it monitors template files for any changes using a checksum and restarts if they change. So in order to do something like you are suggesting, I would have to write another library to handle configuration files just for minecraft.
Thanks for taking the time to do what you did, I just don't feel its a proper fix.
*EDIT* I would also have to write code to read in and monitor banned-ips.txt and banned-players.txt as well, the server modifies the headers in those files as well.
Sorry to spam this ticket so much. You said above though it only adjusts the files in two cases. I have found this to not be the case either. While trying to match the order of the file in my template last night, I realized while restarting the daemon a bunch of times the order of server.properties changes. If you start up a vanilla server and restart the server a handful of times, the order that was first generated is changed eventually if you make any changes of your own.
Is this still an issue in the most recent versions (currently that is 1.10.2, or 16w42a) of Minecraft? If so, please update the affected versions and help us keeping this ticket updated from time to time.
This is still an issue and was reported again (now marked Resolved Invalid - apparently random property order is a feature) in MC-151790. All attempts to have this small server-management annoyance (which will have a trivial fix I expect) seem to eventually get closed without resolution.
This is still an issue in recent editions. Minecraft continues to write properties in a manner that reorders the contents - a function of the hash-order (Java-version dependent) and which entries are in the properties map (configuration and Minecraft version dependent).
I expect the cause is simply that Minecraft is using the rather naive property writing logic built into the ancient class in Java. This JDK issue is tracking a proposed change to provide deterministic writing order and would, I expect, resolve most complaints in this Minecraft issue. However, depending on the JDK solution arrived at (likely in Java 18), Minecraft may need to opt-in to a new storage method.
This report is currently missing crucial information. Please take a look at the other comments to find out what we are looking for.
If you added the required information and a moderator sees your comment, they will reopen and update the report. However, if you think your update to this report has been overlooked or you want to make sure that this report is reopened, you can contact the Mojira staff on Discord or Reddit.
-- I am a bot. This action was performed automatically! If you think it was incorrect, please notify us on Discord or Reddit
To make things worse, even with a stock server.properties file after a few restarts of the server, the order changes. So even if I could work around the timestamp issue with a partial template, I can't count on the order of the settings, so the server will off and on make changes to my partial template as well.
I would really like to server the server stop modifying any configuration files that already exist in the future. Let the server admin worry about updating their configuration files on there own. Please