Steps for using the provided scripts and setting up the Paper MC server as a systemd service. This will allow you to control the server with systemctl
and interact with it using the minecraft
command.
Create a user account named minecraft
. This will be the service account for running the server.
sudo useradd -m -r minecraft
sudo passwd minecraft
Log into the minecraft service account. Download Paper server from: https://papermc.io/software/paper
Place the server in /home/minecraft/paper
then rename the Paper server executable file to server.jar
.
Using the commands below, replacing for the correct download URL and filename:
mkdir paper
cd paper
wget https://api.papermc.io/v2/projects/paper/GETLATESTFROMWEBSITE
mv paper-x.xx.x-xxx.jar server.jar
Note: If this is the first time you're running Paper on your server, you'll want to manually run it at this point to agree to its EULA.
Run:
java -Xms4G -Xmx4G -jar server.jar --nogui
And follow the on screen prompts.
Switch back to your primary account with sudo access.
Clone this repo:
git clone https://github.com/AtomicSponge/paper-systemd.git
cd paper-systemd
Place the file minecraft
in /usr/local/bin
and make sure it has execute permissions by running:
chmod 555 minecraft
sudo mv minecraft /usr/local/bin
Place files minecraft.service
and minecraft.socket
in /etc/systemd/system
:
sudo mv minecraft.service /etc/systemd/system
sudo mv minecraft.socket /etc/systemd/system
Then to start the service run:
sudo systemctl enable minecraft
Default memory setting is 4GB, to change edit minecraft.service
and update the following under ExecStart
to your desired values:
-Xms4096M -Xmx4096M
Commands are passed to the server via the provided script.
To run commands, enter the server command after minecraft
:
minecraft kick PlayerName
Note: Do not use / before the command name
To view server output use the journalctl
command.
For example, this will monitor the log:
journalctl -u minecraft -f
For a list of server commands see: https://minecraft.fandom.com/wiki/Commands
Service script is using the Aikar's flags from: https://docs.papermc.io/misc/tools/start-script-gen
journalctl
manual:
https://www.freedesktop.org/software/systemd/man/latest/journalctl.html#
Adapted from: https://unix.stackexchange.com/a/612118