Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/atomicsponge/paper-systemd

Control Paper Minecraft server with systemd
https://github.com/atomicsponge/paper-systemd

linux minecraft minecraft-server minecraft-server-management papermc script server systemd systemd-service

Last synced: 2 days ago
JSON representation

Control Paper Minecraft server with systemd

Awesome Lists containing this project

README

        

# Paper MC systemd scripts

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 Service Account

Create a user account named `minecraft`. This will be the service account for running the server.
```
sudo useradd -m -r minecraft
sudo passwd minecraft
```

## Download Paper MC

Log into the minecraft service account. Download __Paper__ server from:

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.

## Configure scripts

Switch back to your primary account with __sudo__ access.

Clone this repo:
```
git clone https://github.com/AtomicSponge/paper-systemd.git
cd paper-systemd
```

Create link of file `minecraft-console.py` in `/usr/local/bin` and make sure it has execute permissions by running:
```
chmod 555 minecraft-console.py
sudo ln minecraft-console.py /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
```

## Memory Setting

Default memory setting is 4GB, to change edit `minecraft_java.env` and update `JAVA_OPTS` to your desired values::
```
-Xms4096M -Xmx4096M
```

## Usage

Commands are passed to the server via the provided script `minecraft-console.py`.

To run commands, open console by running `minecraft-console`.

After executing the command, you will see the server log from `journalctl` and a prompt to enter the command.

To exit the console, press CTRL+C

*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
```

-----

### References

For a list of server commands see:

Service script is using the Aikar's flags from:

`journalctl` manual:

Adapted from: