This gist contains service descriptors which may be used to automatically start and re-start Minecraft servers using systemd. This allows proper control of your server startup on modern Linux distributions and will automatically manage all required tasks on startup for you.
- A Linux distribution with systemd support
- A bit of patience
These scripts do not expect any user interaction with the server and thus
may not be feasible for you. If you wish to interact with the server you
may extend the ExecStart
properties with a command like screen
or tmux
. Please refer to other guides for more information on how
to setup these tools.
Note: Not for users of BungeeCord. Single server setups only!
- Place the
minecraft.service
file in your/etc/systemd/system/
directory - Create a user called
minecraft
with its home pointed to/opt/minecraft
- Customize the file according to your requirements as documented within the file
- Install the vanilla server or Spigot in
/opt/minecraft
- (Optional) Enable the service using
systemctl enable minecraft
- Start the service using
systemctl start minecraft
While the step of enabling the service is optional, you should do so to automatically start the server when the machine reboots.
- Place the
bungeecord.service
file in your/etc/systemd/system/
directory - Create a user called
bungeecord
with its home pointed to/opt/bungeecord
- Customize the file according to your requirements as documented within the file
- Install BungeeCord in
/opt/bungeecord/
- (Optional) Enable the service using
systemctl enable bungeecord
For every server you want to add repeat these steps:
- Copy the
minecraft-bungeecord.service
file in your/etc/systemd/system/
directory and give it a descriptive name (lobby.service
for example) - Create a user for the server (using the same name as the service is recommended), also give it a dedicated home directory
- Customize the file according to your requirements as documented within the file
- Install the vanilla server or Spigot in the home directory
- (Optional) Add the server to BungeeCord's dependencies in
/etc/systemd/systemctl/bungeecord.service
Note: The dependency approach will automatically start your servers when BungeeCord starts and thus you will only need
to enable/start the bungeecord
service.
Reading about the
-XX:MaxDirectMemorySize
option (https://www.eclipse.org/openj9/docs/xxmaxdirectmemorysize/), it says:But the settings here have this option set to 200% of the max heap size (
-XX:MaxDirectMemorySize=1G
and-Xmx512M
). Is this intentional?The example
minecraft.service
file worked great for me though. I was just using the default "ubuntu" user in Oracle Cloud's Ubuntu image, and I already had a JRE (Microsoft's ARM64 build of Java 16) and the server.jar file downloaded into my home directory. So I edited the service to use those files where they already were, and it worked fine. Minecraft starts automatically when the VM is rebooted.