PrivateDonut
Account Closedbanned
LEVEL 31
71 XP
Today I will be showing you how to make your server into a service with systemd.
One reason to set up a server as a service is to keep it running continuously, even if the server or host is restarted. This ensures that the server will come back online as quickly as possible.I will assume you already have a server setup on linux, if not you can follow my tutorial How To Compile Trinity Core 3.3.5a On Debian 11 – Step By Step Tutorial
Now that you are in the right directory, we will create the authserver.sh first.
This should open a blank file, where we will insert the following lines.
Let’s give this shell excusable permissions.
We will start off by making the authserver.service first, and you may do that by typing:
Then we will insert the following information:
After you have inserted the following information, to save the file, press ‘Control + O’ and then ‘Control + X’. Now we will create a similar file for the worldserver.
Now we will make it so the services will always try to stay on by typing out the following commands.
You have reached the end of my tutorial, it’s that simple to set your server up as a service and enable it to start upon crashing, restarting or rebooting your host.
One reason to set up a server as a service is to keep it running continuously, even if the server or host is restarted. This ensures that the server will come back online as quickly as possible.I will assume you already have a server setup on linux, if not you can follow my tutorial How To Compile Trinity Core 3.3.5a On Debian 11 – Step By Step Tutorial
Step 1: Creating Shell Scripts For Your Authserver And Worldserver
If you happened to followed along with my tutorial on how to compile trinity core on Debian, you can follow the steps in this tutorial exactly. Otherwise, I will assume you know where to find the necessary files.cd /home/trinitycore/Server/bin
ls

Now that you are in the right directory, we will create the authserver.sh first.
sudo nano worldserver.sh
This should open a blank file, where we will insert the following lines.
#!/bin/bash
./authserver
After you have completed that, simply hit control+o followed by control+x to exit the file. Now we need to make the file excusable.
sudo chmod +x authserver.sh
Now complete the steps again for the worldserver.sh.
sudo nano worldserver.sh
Enter the same text but sightly modified for the worldserver.
#!/bin/bash
./worldserver
Let’s give this shell excusable permissions.
sudo chmod +x worldserver.sh
Step 2: Making The Service Files & Enabling Boot On Startup
We will now be navigating to systemd->system, where we will need to create two new system files.cd /etc/systemd/system/
We will start off by making the authserver.service first, and you may do that by typing:
sudo nano authserver.service
Then we will insert the following information:
[Unit]
Description=auth
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=trinitycore
WorkingDirectory=/home/trinitycore/Server/bin
ExecStart=/bin/bash /home/trinitycore/Server/bin/authserver.sh
[Install]
WantedBy=multi-user.target
After you have inserted the following information, to save the file, press ‘Control + O’ and then ‘Control + X’. Now we will create a similar file for the worldserver.
We will then insert the following information:sudo nano worldserver.service
If you did not follow the tutorial on how to compile on Debian, you may need to modify the file locations and user references in the script.[Unit]
Description=worldserver
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=trinitycore
WorkingDirectory=/home/trinitycore/Server/bin
ExecStart=/bin/bash /home/trinitycore/Server/bin/worldserver.sh
[Install]
WantedBy=multi-user.target
Step 3: Enabling Boot On Startup
We will start the new services to make sure that there are no errors. If you followed this tutorial correctly, there should not be any errors.sudo systemctl start worldserver
sudo systemctl start authserver
Now we will make it so the services will always try to stay on by typing out the following commands.
You should see some text similar to this:sudo systemctl enable worldserver
sudo systemctl enable authserver
Created symlink /etc/systemd/system/multi-user.target.wants/authserver.service → /etc/systemd/system/authserver.service.
You have reached the end of my tutorial, it’s that simple to set your server up as a service and enable it to start upon crashing, restarting or rebooting your host.
Last edited: