Teamspeak Service - Restart After Server Restarts

Good Day Folks,

I did post about this some months ago but have since moved from Apache to NGINX (maybe no different for this) and I am having trouble getting TS to start as a service.

I created a file here /lib/systemd/system/ts3server.service with the following:

[Unit]
Description=Teamspeak Service
Wants=network.target

[Service]
WorkingDirectory=/home/smiley/ts3
User=teamspeak
ExecStart=/home/smiley/ts3/ts3server_minimal_runscript.sh
ExecStop=/home/smiley/ts3/ts3server_startscript.sh stop
ExecReload=/home/smiley/ts3/ts3server_startscript.sh restart
PIDFile=/home/smiley/ts3/ts3server.pid
Restart=always
RestartSec=15

[Install]
WantedBy=multi-user.target

Needless to say it did not work :slight_smile:
But after I noticed there is no ts3server_startscript.sh stop file in my directory?? Not sure why, not something I would have deleted for example.

Can anyone please spring some light on this for me. It is not a huge problem to manually start ts3 but still, easier if it starts itself :slight_smile:

Thank you
Smiley

I can’t find any issue in your script, means it seems to be correct.

I don’t know why people are placing the service files directly in your system(d) directories.
I would always recommend to create the file in your local app path and register/enable it.
Your system will automatically create all necessary symbolic links.
In your case /multi-user.target.wants is missing.

There is a ts3server_startscript.sh file in your app path by default.
stop is just the argument you’re passing to the file.

You can pass other arguments as well to the executable.
For example instead of using the minimal startscript you can also use the (default) startscript passing arguments to it, like the ini file etc:

ExecStart=/home/smiley/ts3/ts3server_startscript.sh start inifile=ts3server.ini

How to register/enable your service script?

(1) Create your script file with it’s content.

[Unit]
Description=Teamspeak Service
Wants=network.target

[Service]
User=teamspeak
WorkingDirectory=/home/smiley/ts3
ExecStart=/home/smiley/ts3/ts3server_minimal_runscript.sh
ExecStop=/home/smiley/ts3/ts3server_startscript.sh stop
ExecReload=/home/smiley/ts3/ts3server_startscript.sh restart
PIDFile=/home/smiley/ts3/ts3server.pid
RestartSec=15
Restart=always

[Install]
WantedBy=multi-user.target

(2) Save the file in your local app path.

/home/smiley/ts3/teamspeak.service

(3) Reload all (system) unit files

sudo systemctl daemon-reload

(4) Register/enable your teamspeak.service file

sudo systemctl enable /home/smiley/ts3/teamspeak.service

The result will be, as I mentioned above:

Your system will automatically create all necessary symbolic links.


Make sure the service is started after and it’s running.

sudo systemctl start teamspeak.service
sudo systemctl status teamspeak.service

Removing the service and all symbolic links

sudo systemctl stop teamspeak.service 
sudo systemctl disable teamspeak.service
sudo systemctl daemon-reload 

That’s it.

4 Likes

Awesome reply. Thank you.

So when i restarted the machine TS never started.

This is my output of status and i see the symlink in /etc/systemd/system/teamspeak.service

(code=exited, status=217/USER)

Does the system user teamspeak exists?
The error in general means the user doesn’t exist.

Did you add the user and change the permissions for it on your whole TeamSpeak directory?

Doh!!! how silly I feel …it is under my user smiley…

I will change…see how that goes

UPDATE: Worked a treat.Thanks again…Could not see for looking haha :slight_smile:

1 Like
twitch instagram twitter facebook