Minecraft Server Hibernation
Avoid wasting of resources by automatically starting your minecraft server when a player join and stopping it when no one is online
(for vanilla/modded on linux/windows/macos)
version: v2.4.4
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/gekware/minecraft-server-hibernation.git
cd minecraft-server-hibernation/
go build .
INSTRUCTIONS:
- Install your desired minecraft server
- Edit the parameters in config file as needed (check definitions):
- Folder
- FileName
- StartServerParam
- StopServer
- * StopServerAllowKill
- * HibernationInfo and StartingInfo
- * TimeBeforeStoppingEmptyServer
- * NotifyUpdate
- * put the frozen icon you want in
path/to/server.jar/folder
(must be 64x64 and calledserver-icon-frozen.png
) - on the router (to which the server is connected): forward port 25555 to server (tutorial)
- on the server: open port 25555 (example: ufw firewall)
- run the msh executable
- you can connect to the server through port 25555
* = it's not compulsory to modify this parameter
remember to automatically run msh at reboot
DEFINITIONS:
only text in braces needs to be modified (remember to remove all braces)
Location of server folder and executable. You can find protocol/version here (but msh should set them automatically):
"Server": {
"Folder": "{path/to/server/folder}",
"FileName": "{server.jar}",
"Protocol": 756,
"Version": "1.17.1"
}
Commands to start and stop minecraft server:
"Commands": {
"StartServer": "java <Commands.StartServerParam> -jar <Server.FileName> nogui",
"StartServerParam": "-Xmx1024M -Xms1024M",
"StopServer": "stop",
"StopServerAllowKill": 10
}
# if StopServerAllowKill is more than 0, then the specified number is the amount of seconds
# given to the minecraft server to go offline, after which it is killed
Set the logging level for debug purposes
"Debug": 1
# 0 - NONE: no log
# 1 - BASE: basic log
# 2 - SERV: mincraft server log
# 3 - DEVE: developement log
# 4 - BYTE: connection bytes log
Hibernation and Starting server description
"InfoHibernation": " §fserver status:\n §b§lHIBERNATING",
"InfoStarting": " §fserver status:\n §6§lWARMING UP",
Set to false if you don't want to notify updates in game chat (every 20 minutes)
"NotifyUpdate": true
60 seconds is the time (after the last player disconnected) that the script waits before hibernating the minecraft server
"TimeBeforeStoppingEmptyServer": 30 #any parameter more than 30s is recommended
Some of these parameters can be configured with command-line arguments (--help to know which)
CREDITS:
Author: gekigek99
Contributors: najtin, f8ith, Br31zh, someotherotherguy, navidmafi, cromefire
Docker branch: lubocode
If you wish to contribute, please create a pull request using the dev branch as the base for your changes