GameServer Service Setup

From ScottWiki
Revision as of 17:17, 15 December 2022 by Wikiadmin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Firstly we need to create the service file in /etc/systemd/system/

nano /etc/systemd/system/MyGameServer.service

In this file we put all the details about the service we want to run.

[Unit]
Description=MyGameServer Server Control Script
Documentation=
Requires=network.target
After=network.target

[Service]
User=gameserver     <---- this is username we want the service to run under
Group=gameserver    <---- this is the group we want the service to run under.
Environment="PATH=/usr/local/bin:/usr/bin:/bin"
ExecStart=/srv/data/game_servers/scripts/MygameService.sh       <---- here we point to the shell script that starts the server.
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Now we reload the daemon, to read in the file we just created.

systemctl --system daemon-reload

Now enabled the service with

systemctl enable MyGameService.service

Now start the service with the cmd.

systemctl start MyGameService.service


Once you've started the server, you can check that it's running with this command.

systemctl status MyGameService.service