We host our games on a spare box at home, so it gets switched off when everybody is done playing.
I realised that mineos.service only invokes “/usr/bin/node service.js stop”, which kills the webui, but leaves the minecraft games running. When the machine shuts down, the games get killed without saving, corrupting them.
I have written a mineos_shutdown.js script, which lists the running games and stops them, and added it to mineos.service. Could I contribute it to the codebase?
All are welcome to produce Pull Requests on github to improve/amend the MineOS-node codebase.
In this specific case, however, I’m inclined to not tie shutting down the webui service with shutting down Minecraft servers… at least not as the default behavior.
People may want to update the webui while servers are running–and this is possible without impacting the Minecraft servers currently running.
Almost all Linux distributions have a means to execute scripts on shutdown/reboot, and this would be a spectacular place to put in your mineos_shutdown.js script to ensure your servers are appropriately and cleanly downed before the machine halts.
Also, if you would like to share your shutdown script (even here), we can ensure it’s the cleanest/generalizable possible and hopefully others can find good use to it!
Sounds sensible. I will try to create a separate SystemD unit file that just invokes mineos_shutdown.js, to make it easier to install.
… and then learn how this “pull-request” thingy works
Well, in my opinion it could be tied into the main MineOS base, so long as it isn’t called then restarting/updating the web ui; just like how the system starts up and automatically starts the MineOS web ui service, the system can (or should be able to) also automatically start that script on system shutdown, probably after stopping the MineOS service (again not tied to the actual service) or before. Speaking of which, I believe an automatic web ui restart function should be added to the update and reset convenience scripts (so that they’re applied immediately).
Right.
I have now written the systemd unit file that calls the server stop script on system shutdown.
Am I best posting the script/unit file here, or doing a proper pull request?
Can I ask how you did the systemd file? I aswell have made my own script to properly save and shut down my server. when I manually run it the script it works, but i’ve been been trying to make a the systemd service to run my script when the pc is shutdown, and I can’t for the life of me get it my systemd service to work,
it doesn’t even seem to attempt to run my script. I’ve been reading through forum after forum on systemd services and i don’t get what I’ve got wrong with mine.
anyways thanks for your time.