/minecraft-server-hibernation

Autostart and stop minecraft-server when players join/leave

Primary LanguageGoGNU General Public License v3.0GPL-3.0

Minecraft Server Hibernation

msh - release msh - goreport msh - license msh - stars

Avoid wasting of resources by automatically start your minecraft server when a player join and stop it when no one is online
(for vanilla/modded on linux/windows/macos)

version: v2.4.0
Copyright (C) 2019-2021 gekigek99

Check the releases to download the binaries (for linux, windows and macos)

You can compile msh from the dev branch to access a more updated version but beware that it might still need testing


PROGRAM COMPILATION:

This version was successfully compiled in go version 1.15
Compilation procedure:

git clone https://github.com/gekigek99/minecraft-server-hibernation.git  
cd minecraft-server-hibernation/  
go build .

now you can run the msh executable


INSTRUCTIONS:

This is a Golang script to start a minecraft server on request and stop it when there are no players online. How to use:

  1. Install your desired minecraft server
  2. Edit the parameters in config.json as needed (check definitions):
    • Folder
    • FileName
    • StartServer
    • StopServer
    • * StopServerForce
    • * HibernationInfo and StartingInfo
    • * TimeBeforeStoppingEmptyServer
    • * CheckForUpdates
  3. * put the frozen icon you want in "path/to/server.jar/folder" (must be 64x64 and called "server-icon-frozen.png")
  4. on the router: forward port 25555 to server (tutorial)
  5. on the server: open port 25555 (example: ufw firewall)
  6. run the msh executable
  7. you can connect to the server through port 25555

* = it's not compulsory to modify this parameter

(remember to run the set msh to run at reboot)


DEFINITIONS:

only text in braces needs to be modified (remember to remove all braces)

Location of server folder and executable:

"Server":{
  "Folder": "{path/to/server/folder}",
  "FileName": "{server.jar}"
}

Commands to start and stop minecraft server:

"Commands":{
  "StartServer": "java {-Xmx1024M} {-Xms1024M} -jar serverFileName nogui",
  "StopServer": "{stop}",
  "StopServerForce": ""
}

# the StopMinecraftServerForce parameter is used to execute special commands when a forced shutdown happens

Hibernation and warming up server description

"HibernationInfo": "                   \u0026fserver status:\n                   \u0026b\u0026lHIBERNATING",
"StartingInfo": "                   \u0026fserver status:\n                    \u00266\u0026lWARMING UP"

60 seconds is the time (after the last player disconnected) that the script waits before shutting down the minecraft server

"TimeBeforeStoppingEmptyServer": 60     #any parameter more than 30s is recommended

Set to false if you don't want to check for updates

"CheckForUpdates": true

CREDITS:

Author: gekigek99
Contributors: najtin f8ith Br31zh someotherotherguy
Docker branch: lubocode

If you wish to contribute, please create a pull request using the dev branch as the base for your changes


Give a star to this repository on github!