minecraftd is a daemon that hosts a Java Virtual Machine to run a Minecraft server instance. Its notable features include:
Java applications typically do not lend themselves to being run as “normal” service processes, and Minecraft is no exception, with its control channel being standard input (or rcon). This has resulted in solutions such as using GNU Screen to manage the lifecycle of the process, and still allow “keyboard” input to be sent to the server console.
Additionally, because all Java applications are run using the java
executable, process
identification in tools such as top
and ps
become much harder when multiple Java
processes are running simultaneously on a host.
minecraftd addresses both of these concerns. It overrides the process' standard input to a
POSIX pipe, which the D-Bus interface writes to
when its methods are called. This allows D-Bus clients in other processes to communicate with the Minecraft
server console. And because minecraftd is an executable, it will show up in process listings as
minecraftd
, simplyifying identification of the process.
At the most basic level, minecraftd performs the same task as running java -jar minecraft_server.jar. It uses a combination of runtime dynamic linking and the Java Invocation API to create an instance of the JVM, and executes the Minecraft server code contained in the JAR using that JVM.
In addition to that, it registers a D-Bus interface on the system bus, granting D-Bus clients in the system
the ability to communicate with the Minecraft server, e.g. sending it the stop
command to shutdown
the server.
Configuration of minecraftd, and the JVM it hosts, is driven by the contents of the
minecraftd.conf
file. An example configuration enabling use of the concurrent mark-and-sweep
garbage collector in the JVM is given below:
jvm: {
arguments = [
"-XX:+UseConcMarkSweepGC"
];
};
The syntax of the configuration file is that of the libconfig library.
minecraftd's D-Bus interface is registered on the system bus with the following values:
Name | Value |
---|---|
Bus name | net.za.slyfox.Minecraftd1 |
Object name | /net/za/slyfox/Minecraftd1 |
Interface name | net.za.slyfox.Minecraftd1 |
The Minecraftd1
interface consists of the following methods:
Method | Description |
---|---|
SaveAll | Sends the save-all command to the Minecraft server,
causing all chunks to be saved to storage. |
Stop | Sends the stop command to the Minecraft server,
gracefully shutting it down. Typically, the service itself would be stopped instead of using this
command directly, e.g. systemctl stop minecraftd. |