NodeMC / CORE

Core of NodeMC, including stock dashboard and setup files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kill server correctly

JoeNorth opened this issue · comments

Instead of killing the server process with SIGTERM, shouldn't it be done safely doing something like

this.execute("stop");

so the server can shut itself down and not potentially lose data?

Hey, yes this should be done. SIGTERM isn't appropriate anyways, stop is the way to do it and set a timeout for SIGKILL in-case of memory issues and other things I encountered running a Minecraft Server instance on my DigitalOcean droplets where it doesn't listen to signals or stop.

commented

The problem with a SIGKILL timeout is that large servers can take a long time to shut down safely while smaller servers should shut down quickly.

@md678685 Yeah, a timeout is not ideal. Something like a force stop endpoint would be good.

Minecraft's native rcon server might be a better way to handle sending commands to the server if it pings back when the server is down or we can just detect when the connection has died and then know the server is down also.

commented

@JoeNorth I've been considering writing a plugin to utilise RCON instead of stdin, however this means more configuration for the Minecraft server and could potentially also be less reliable than just writing to stdin. Also, I don't think Glowstone supports RCON (may be wrong though). It would probably be better to leave this to a plugin rather than implement into Core.

@md678685 Could easily just modify server.propeties. Already have a good plugin for that, then just use node-rcon.

@jaredallard I think going with RCON could be a better solution going forward, especially if managing multiple servers in a single NodeMC instance is something to be added in future versions. For a single MC instance using STDIN is fine but ultimately isn't very scalable. Beyond that, the current implementation requires NodeMC to be run on the same server as the MC instance which is simply not feasible on a lot of hosting platforms. With RCON, the server can be running on any host, given they allow you to enable RCON, and NodeMC can be run locally.

The only downside I see to running RCON is that the protocol isn't secure (to my knowledge) so passwords, commands, ports, etc. are all sent as plaintext.

commented

@JoeNorth NodeMC is a wrapper around Minecraft servers, and either way you still need to read stdout and stderr since the console isn't output over RCON as far as I'm aware. (I fail to see the point of running NodeMC locally? Starting, configuring and restarting servers won't work - there's no universal way to do that remotely.)