Keeping TS Server Alive After Apache Restart

Hi All.

Is there a way that i can keep Teamspeak server ‘alive’ whilst restarting the webserver (Apache) ?

I do a lot with other things on my server and often restart Apache. TS is the only thing that dies when I do that and have to restart TS each time again.

If there is a way I would like to hear how :grinning:

Thx in advance.

Your teamspeak server shouldn’t shut down when you restart your apache2 web server.
Does your Teamspeak Server crash? (Check log files)

And how do you restart your apache2 web server?
With systemctl restart apache2?
Or do you reboot your whole server / the whole system?

1 Like

Could it be that the server is using MariaDB / MySQL and the Apache restart also restarts the database server?
You can not take the database offline while TS server wants to use it!

OR could it be that a console where server was started in also does close?
Should not be a problem when startscript was used to run the server.

4 Likes

Yes Marcel i use that. TS then shuts down.

Chris, yes the server uses MySQL. I am not sure about any of this tbh. Sorry for noob question.

It is not a HUGE problem but it would be nice not to have to keep restarting it.

When I restart Apache: The last line is added in the log.

2021-06-12 12:31:24.388334|INFO |ServerLibPriv | |TeamSpeak 3 Server 3.13.3 (2020-12-16 14:17:05)
2021-06-12 12:31:24.388424|INFO |ServerLibPriv | |SystemInformation: Linux 4.15.0-144-generic #148-Ubuntu SMP Sat May 8 02:33:43 UTC 2021 x86_64 Binary: 64bit
2021-06-12 12:31:24.388440|WARNING |ServerLibPriv | |The system locale is set to “C” this can cause unexpected behavior. We advice you to repair your locale!
2021-06-12 12:31:24.388452|INFO |ServerLibPriv | |Using hardware aes
2021-06-12 12:31:24.388798|INFO |DatabaseQuery | |dbPlugin name: SQLite3 plugin, Version 3, ©TeamSpeak Systems GmbH
2021-06-12 12:31:24.388817|INFO |DatabaseQuery | |dbPlugin version: 3.11.1
2021-06-12 12:31:24.388922|INFO |DatabaseQuery | |checking database integrity (may take a while)
2021-06-12 12:31:24.413957|WARNING |Accounting | |Unable to open licensekey.dat, falling back to limited functionality
2021-06-12 12:31:24.414066|INFO |Accounting | |Licensing Information
2021-06-12 12:31:24.414081|INFO |Accounting | |licensed to : Anonymous
2021-06-12 12:31:24.414091|INFO |Accounting | |type : No License
2021-06-12 12:31:24.414104|INFO |Accounting | |starting date : Thu Oct 1 00:00:00 2020
2021-06-12 12:31:24.414115|INFO |Accounting | |ending date : Tue Nov 1 00:00:00 2022
2021-06-12 12:31:24.414124|INFO |Accounting | |max virtualservers: 1
2021-06-12 12:31:24.414132|INFO |Accounting | |max slots : 32
2021-06-12 12:31:25.071607|INFO | | |Puzzle precompute time: 643
2021-06-12 12:31:25.071949|INFO |FileManager | |listening on 0.0.0.0:30033, [::]:30033
2021-06-12 12:31:25.073015|INFO |Query | |Using a query thread pool size of 2
2021-06-12 12:31:25.106472|INFO |Query | |listening for query on 0.0.0.0:10011, [::]:10011
2021-06-12 12:31:25.106638|INFO |Query | |listening for ssh query on 0.0.0.0:10022, [::]:10022
2021-06-12 12:31:25.106715|INFO |Query | |listening for http query on 0.0.0.0:10080, [::]:10080
2021-06-12 12:31:25.106776|INFO |CIDRManager | |updated query_ip_allowlist ips: 127.0.0.1/32, ::1/128,
2021-06-12 12:32:21.023865|INFO |ServerMain | |Received signal SIGTERM, shutting down.

Another Log also made:

2021-06-12 12:31:25.106321|INFO |VirtualServerBase|1 |listening on 0.0.0.0:9987, [::]:9987
2021-06-12 12:32:21.024308|INFO |VirtualServerBase|1 |stopped

This is the important line:

2021-06-12 12:32:21.023865|INFO |ServerMain | |Received signal SIGTERM, shutting down.

Maybe tell us how exactly you restart your apache2 webserver.

1 Like

You want to restart the apache2 service right? Just run the Command service apache2 restart
You can see the state of every service with service --status-all

systemctl restart apache2 or service apcahe2 restart --there are a few ways but it does not matter which one i use. The result is the same.

@FakE the locale is set with en_US.UTF-8 - That’s the only entry on that file. I did update the server to 3.16.6 because server was then not getting scanned by Gametracker. I downgraded again. As you said I dont think it is that because it has been like this for many versions.

@TS.ChrisR I start the server with a self made panel on a webpage.

I cannot type the script in a reply because i get an error but it is PHP script basically executing the start.

exec(’/home/smiley/cod4/commands/ts3_start.sh’); exit;

That is the problem. You need to replace the exec command with the actual Startscript. Otherwise the TeamSpeak process is part of the apache process and shutdown with the apache process.

2 Likes

That did not work. Permissions are correct but TS does not start that way. Example: /home/smiley/ts3/ts3server_startscript.sh

I press the button on my webpage and that points to the php file : exec(’/home/smiley/cod4/commands/ts3_start.sh’); exit;

That file /ts3_start.sh) reads:
#!/bin/bash

cd /home/smiley/ts3
./ts3server

Server starts no problem. Have the same with a stop button. Changing the path in the forst instance to the sh file within ts3 directory did not work. Maybe missing something here :frowning:

Try to use systemd to start ts3.

ie: systemctl start ts3 if you have a service with that name.

SOLVED:

I did not have it running as a service. So obviously got me thinking. I did this:

sudo nano /lib/systemd/system/ts3server.service

Then added the script below obviously changing the paths:

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

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

[Install]
WantedBy=multi-user.target

Saved the file and then enabled it : systemctl enable ts3server.service

Rebooted my machine and then checked with: systemctl status ts3server

ts3 was active and running. Now when I restart Apache (disconnects me form ts3 for about 10 seconds and then reconnects) or my machine it stays running. That is also starting and stopping ts3 from my home made control panel.

Thank you all very much for the help and the shove that I needed in the right direction. :woozy_face:

Thanks FakE that a great detailed description. I have done as you said and all seems to be ok :slight_smile:

1 Like