Manage Trackmania Server with systemd

Viewed 143

Hi i just set up a trackmania server which works fine when starting via command line. Now i want to manage it with systemd, so it starts on boot and gets restartet if it crashes.

Here is my systemd service file:

[Unit]  
Description=Trackmania 2020 Server  
After=network.target  

[Service]  
User=trackmania  
Group=trackmania  
Restart=always  
RestartSec=30  
WorkingDirectory=/home/trackmania/server  
ExecStart=/home/trackmania/server/TrackmaniaServer /title=Trackmania /game_Settings=Matchsettings/tracklist.txt /dedicated_cfg=dedicated_cfg.txt  

[Install]  
WantedBy=multi-user.target  

When starting the service, the status command returns:

* trackmania_server.service - Trackmania 2020 Server  
   Loaded: loaded (/etc/systemd/system/trackmania_server.service; disabled; vendor preset: enabled)  
   Active: activating (auto-restart) since Thu 2020-07-09 21:08:31 UTC; 29s ago  
  Process: 1759 ExecStart=/home/trackmania/server/TrackmaniaServer /title=Trackmania /game_Settings=Matchsettings/tracklist.txt /dedicated_cfg=dedicated_cfg.txt (code=exited, status=0/SUCCESS)  
 Main PID: 1759 (code=exited, status=0/SUCCESS)  

When stopping the service this is returned:

* trackmania_server.service - Trackmania 2020 Server  
   Loaded: loaded (/etc/systemd/system/trackmania_server.service; disabled; vendor preset: enabled)  
   Active: inactive (dead)  

Jul 09 21:11:03 vps-zap558747-2 systemd[1]: Started Trackmania 2020 Server.  
Jul 09 21:11:03 vps-zap558747-2 TrackmaniaServer[1847]: Starting Trackmania Date=2020-07-07_23_30 Svn=105917 GameVersion=3.3.0...  
Jul 09 21:11:03 vps-zap558747-2 TrackmaniaServer[1847]: ManiaPlanet server daemon started with pid=1848 (parent=1847).  
Jul 09 21:11:03 vps-zap558747-2 TrackmaniaServer[1847]: Configuration file : dedicated_cfg.txt  
Jul 09 21:11:03 vps-zap558747-2 TrackmaniaServer[1847]: Loading system configuration...  
Jul 09 21:11:03 vps-zap558747-2 TrackmaniaServer[1847]: ...system configuration loaded  
Jul 09 21:11:04 vps-zap558747-2 TrackmaniaServer[1847]: Loading cache...  
Jul 09 21:11:04 vps-zap558747-2 TrackmaniaServer[1847]: ...OK  
Jul 09 21:11:04 vps-zap558747-2 systemd[1]: trackmania_server.service: Succeeded.  
Jul 09 21:11:04 vps-zap558747-2 systemd[1]: Stopped Trackmania 2020 Server.  

To me it looks like the server is started when i stop the service and well then immediately terminated again. What am i doing wrong? o.O

1 Answers

Try using the /nodaemon switch on the server command line

Related