Minecraft in SCREEN session
You can find a few solutions with screen
application, with it you can run Minecraft server in background and access game console.
Sadly you cannot easily send commands (eg. /stop
) to screen session, existing solutions are sometimes complicated and just don't work.
Solutions found by me are just not enough (in my opinion).
To access screen session from another user account firstly you have to configure screen to allow it. Additionally when in screen session you can accidentally close running server by exiting screen. I've also stumbled on problems with double daemonization - init script cannot find Minecraft PID if screen daemonizes itself.
Exemplary server daemon script using screen
command:
http://minecraft.gamepedia.com/Tutorials/Server_startup_script
Something better
Main problem to solve was access to game console and safe server shutdown to allow Minecraft save world data. And it also enables logging to system logger!
MiencraftD script: https://github.com/glorpen/gentoo-overlay/blob/master/games-server/minecraft/files/minecraftd.py
Adventages
server logs are written to system logs
start/stop actions available from command line
safe shutdown - it is Minecraft server who determines when to exit
game console is available
sending server commands from command line
Requirements
python 2.7 lub 3.3+
python-daemon
lockfile
Usage
usage: minecraftd.py [-h] [--instance INSTANCE] {start,shell,stop,cmd} ... Minecraft server daemonizer positional arguments: {start,shell,stop,cmd} start Starts minecraft daemon for given instance shell Connects to Minecraft shell of given instance stop Stops Minecraft daemon for given instance cmd Sends command to given instances shell optional arguments: -h, --help show this help message and exit --instance INSTANCE, -i INSTANCE Instance name
Download
This script is part of my portage overlay:
Gentoo overlay: https://github.com/glorpen/gentoo-overlay
Ebuild for Minecraft server: https://github.com/glorpen/gentoo-overlay/tree/master/games-server/minecraft
init.d
script for MinecraftD: https://github.com/glorpen/gentoo-overlay/blob/master/games-server/minecraft/files/minecraft.daemon.d
Again, Minecraft server daemonizer: https://github.com/glorpen/gentoo-overlay/blob/master/games-server/minecraft/files/minecraftd.py