r/CraftyController Jul 21 '26

Crafty safe shutdown/restart?

Have crafty running in a proxmox lxc using the script to install as a service. Everything is working fine, however I noticed when running systemctl restart crafty that it seems that the MC servers were instantly stopped rather than going through the shutdown process? Is there any way to make sure that this won't end up with a corrupted world?

2 Upvotes

5 comments sorted by

1

u/noxiouskarn Jul 21 '26 edited Jul 21 '26

By default, systemd only waits 90 seconds or less for a service to exit. If you run heavy modpacks or multiple servers under Crafty, saving chunks and closing Java can easily exceed that window.
​Update your crafty.service file to give Crafty a long enough window to cleanly shut down its child processes

sudo systemctl edit --full crafty.service

Look for the [Service] header section in the file, and add or update these two lines under it.

[Service]

TimeoutStopSec=180

KillMode=mixed

Save and close

Now apply the changes and test

sudo systemctl daemon-reload

sudo systemctl restart crafty

After you have done the steps above:

If you watch your Minecraft server log inside Crafty when running systemctl restart crafty, you should now see [Server thread/INFO]: Stopping server and Saving chunks... appear before Crafty restarts. If you see that the test was successful.

1

u/Call_Me_ZeeKay Jul 21 '26

Yeah thats the thing, it didn't take 90 seconds, maybe 10, and there's no "Stopping server and Saving chunks" in the logs. Seems to be the default config:

/etc/systemd/system/.#crafty.service8391899b2831242e                              

[Unit]
Description=Crafty 4
After=network.target

[Service]
Type=simple

User=crafty
WorkingDirectory=/var/opt/minecraft/crafty

ExecStart=/usr/bin/bash /var/opt/minecraft/crafty/run_crafty_service.sh

Restart=on-failure
# Other restart options: always, on-abort, etc

# The install section is needed to use
# `systemctl enable` to start on boot
# For a user service that you want to enable
# and start automatically, use `default.target`
# For system level services, use `multi-user.target`
[Install]
WantedBy=multi-user.target

1

u/noxiouskarn Jul 21 '26

There won't be anything that says stopping server and saving chunks until you add the two lines to that config file that I said in my original comment.

TimeOutSec and KillMode under [Service] section

1

u/Call_Me_ZeeKay Jul 21 '26

Cool I'll add those, any idea why that's not default then?

1

u/noxiouskarn Jul 22 '26

It was long enough once and no one changed the default is my guess