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.
These service files are about 5 years old by now (in fact I'm surprised that anybody actually stumbled across them after all this time) so take any assumptions in here with a grain of salt.
That being said: I believe
MaxDirectMemorySize
is deliberately increased in the BungeeCord template as the application didn't use to require any actual heap memory. Generally, it would store everything needed for its job in direct buffers (inbound, outbound, and anything in between uses direct buffers). As a result, you could end up exhausting the direct buffer space (and subsequently drop connections) in deployments with small amounts of heap memory (as would be the case if you just used it as a plain protocol-aware proxy).I should point out though that I am no longer involved with BungeeCord and/or Spigot (and haven't been in quite a few years) so these statements may no longer hold true (if they were ever truly accurate given that a lot of suggestions back then were just passed along as religious gospel). These files were primarily meant to be simple guides for standard small deployments to cut down on reoccurring support cases we had to deal with back then (mostly from kids who would run these setups on Raspberries and similar low-powered hardware).