minecraft-vanilla-server-hibernation

command module
v2.1.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

README

Minecraft Server Hibernation

msh - license msh - stars msh - release

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.1.2
Copyright (C) 2019-2021 gekigek99

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


PROGRAM COMPILATION:

This version was successfully compiled in go version 1.15 To compile run the command:

go build minecraft-server-hibernation.go

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. "server-port" parameter in "server.properties" should be 25565
  3. Edit the parameters in config.json as needed (check definitions):
    • serverDirPath
    • serverFileName
    • startMinecraftServerLin or startMinecraftServerWin
    • stopMinecraftServerLin or stopMinecraftServerWin
    • *hibernationInfo and startingInfo
    • *minecraftServerStartupTime
    • *timeBeforeStoppingEmptyServer
    • *checkForUpdates
  4. *put the frozen icon you want in "path/to/server.jar/folder" (must be 64x64 and called "server-icon-frozen.png")
  5. on the server: open port 25555 (example: ufw firewall)
  6. on the router: forward port 25555 to server (tutorial)
  7. you can connect to the server through port 25555

* = this step is NOT strictly necessary

(remember to run the script at reboot)

DEFINITIONS:

Commands to start and stop minecraft server:

# only text in braces needs to be modified (remember to remove all braces)
"serverDirPath": "{path/to/server/folder}",
"serverFileName": "{server.jar}",
"startMinecraftServerLin": "screen -dmS minecraftServer java {-Xmx1024M -Xms1024M} -jar serverFileName nogui",
"stopMinecraftServerLin": "screen -S minecraftServer -X stuff 'stop\\n'",
"startMinecraftServerWin": "java {-Xmx1024M -Xms1024M} -jar serverFileName nogui",
"stopMinecraftServerWin": "stop",

# you must launch the program as root, otherwise the screen command won't be executed successfully
# if you are on linux you can access the minecraft server console with "sudo screen -r minecraftServer"

Personally I set up a systemctl minecraft server service (called "minecraft-server") therefore I use:

"startMinecraftServerLin": "sudo systemctl start minecraft-server",
"stopMinecraftServerLin": "sudo systemctl stop minecraft-server",

Hibernation and warming up server description

"hibernationInfo": "                   &fserver status:\n                   &b&lHIBERNATING",
"startingInfo": "                   &fserver status:\n                    &6&lWARMING UP",

If you are the first to access to minecraft world you will have to wait 20 seconds and then try to connect again.

"minecraftServerStartupTime": 20,       #any parameter more than 10s is recommended

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
Docker branch: lubocode


Give a star to this repository here!

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL