I wrote a small daemon application in .NET last year that basically launches a Minecraft server, and provides a web based GUI to manage it. It does other things such as restart the process if it crashes, and other useful functions.
Our company recently heard of a french hosting company that had setup their servers in a way that when the last player disconnected, the server would shutdown until another player joined. Now, I have been thinking about how this might be possible, and wanted to see what the thoughts on it were. My daemon can already tell how many players are connected, so that is not an issue.
My psuedo thought process is…
- Last Player disconnects from server
- Daemon takes over listening on the server port for connections
- Upon incoming connection, save the connection packet data and restart the server sub-process
- Pass the save connection on to the Minecraft java process
I can’t really figure out how to handle the last step yet, but that is the best solution I have come up with. Any thoughts or suggestions?
Perhaps you’ll have more players wanting to connect at once, so you might have problems with that approach (cuz i’m guessing your server won’t start instantaneously).
You should have a daemon waiting for connections and putting them on a queue or something, until the server starts, and feed it then, the connections (or connection packets or whatever). After the server is started, and all connections have been forwarded to it, get your daemon to “stop” (a.k.a die or stop clogging the port)
Hope this helps.