gekware / minecraft-server-hibernation

Autostart and stop minecraft-server when players join/leave
GNU General Public License v3.0
380 stars 38 forks source link

freeze and unfreeze server to avoid warming up delay and cpu spikes #51

Closed Br31zh closed 2 years ago

Br31zh commented 3 years ago

Hello,

That’s not really an issue, but I wanted to share this and don’t know where I can say it: I have my server on my (Linux) PC, and starting the server create CPU usage pikes, and freezes my other programs. So, instead of shutdown the server, I freeze it with a kill -STOP <pid> and resume with kill -CONT <pid>. It constantly use the 2GB of assigned RAM, but CPU, disk and network usage are null during this time. And the resume is instant, without CPU spike.

I had to set max-tick-time to -1 in server.properties and start the server before your script (and, since your script expect the server to be down, I freeze it before launching your script). I set the startup time to 1 in the configuration, and I resume the server before stopping it in my shutdown script (used when I want to completely stop the server).

It can give idea to others people, or to add new functionalities to the script, or as an example since it’s not an obvious way to use it.

gekigek99 commented 2 years ago

@debian-user-france1 what do you mean? you won't play minecraft anymore? :(

arch-user-france1 commented 2 years ago

@debian-user-france1 what do you mean? you won't play minecraft anymore? :(

I won't play minecraft anymore since it requres a microsoft account.

gekigek99 commented 2 years ago

Yeah i know it's stupid the fact they oblige in this way

Br31zh commented 2 years ago

@Br31zh did you try this new feature? does it behave as expected?

So, I just tested it (v2.4.7 pre-release), it works like a charm, except one small bug: when I’m sending commands on standard input, sometimes it doesn’t send it to minecraft. Then a user connect or disconnect and then the command is send.

After some tests, I think that’s because msh is waiting for a response in the console, but this command (dynmap sendtoweb msg, it’s from a mod) don’t give any response. It’s maybe worth to add a timeout on this wait?

(PS: I can make another issue for this if you want, since it’s not linked to the freeze feature)

gekigek99 commented 2 years ago

Yes if you can open an other issue it would be great.

As there are currently some other bugs related to the ms freeze/unfreeze.