Systemd Unit: Difference between revisions

From TeamSpeak Wiki
Jump to navigation Jump to search
(Created page with "This mainly applies to CentOS 7 and Ubuntu 18.04+, there are advantages to using this method as it also enables monitoring of the TeamSpeak 3 Server as well as starting the Te...")
 
No edit summary
 
Line 2: Line 2:


Copy the following in to a systemd unit file of your choosing, we'll use /etc/systemd/system/teamspeak.service, you will need to change the lines WorkingDirectory, ExecStart, ExecStop and ExecReload if you installed the server in a different folder and the user= line if you made a UNIX user other than "teamspeak".
Copy the following in to a systemd unit file of your choosing, we'll use /etc/systemd/system/teamspeak.service, you will need to change the lines WorkingDirectory, ExecStart, ExecStop and ExecReload if you installed the server in a different folder and the user= line if you made a UNIX user other than "teamspeak".
 
[Unit]
    [Unit]
Description=TeamSpeak3 Server
    Description=TeamSpeak3 Server
Wants=network-online.target
    Wants=network-online.target
After=syslog.target network.target
    After=syslog.target network.target
[Service]
WorkingDirectory=/home/teamspeak/teamspeak3-server_linux-amd64/
User=teamspeak
Type=forking
ExecStart=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server_startscript.sh start initfile=ts3server.ini
ExecStop=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server_startscript.sh stop
ExecReload=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server_startscript.sh restart
PIDFile=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server.pid
      
      
    [Service]
[Install]
    WorkingDirectory=/home/teamspeak/teamspeak3-server_linux-amd64/
WantedBy=multi-user.target
    User=teamspeak
    Type=forking
    ExecStart=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server_startscript.sh start initfile=ts3server.ini
    ExecStop=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server_startscript.sh stop
    ExecReload=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server_startscript.sh restart
    PIDFile=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server.pid
   
    [Install]
    WantedBy=multi-user.target
 
After you've saved the file you need to enable the unit by running :
After you've saved the file you need to enable the unit by running :
   
systemctl enable teamspeak
    systemctl enable teamspeak
 
As a bonus, you can now use systemd to start, stop and reload your server by using  
As a bonus, you can now use systemd to start, stop and reload your server by using  
 
systemctl start teamspeak
    systemctl start teamspeak
systemctl stop teamspeak
    systemctl stop teamspeak
systemctl reload teamspeak
    systemctl reload teamspeak

Latest revision as of 12:59, 6 January 2021

This mainly applies to CentOS 7 and Ubuntu 18.04+, there are advantages to using this method as it also enables monitoring of the TeamSpeak 3 Server as well as starting the TeamSpeak instance on boot.

Copy the following in to a systemd unit file of your choosing, we'll use /etc/systemd/system/teamspeak.service, you will need to change the lines WorkingDirectory, ExecStart, ExecStop and ExecReload if you installed the server in a different folder and the user= line if you made a UNIX user other than "teamspeak".

[Unit]
Description=TeamSpeak3 Server
Wants=network-online.target
After=syslog.target network.target

[Service]
WorkingDirectory=/home/teamspeak/teamspeak3-server_linux-amd64/
User=teamspeak
Type=forking
ExecStart=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server_startscript.sh start initfile=ts3server.ini
ExecStop=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server_startscript.sh stop
ExecReload=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server_startscript.sh restart
PIDFile=/home/teamspeak/teamspeak3-server_linux-amd64/ts3server.pid
   
[Install]
WantedBy=multi-user.target

After you've saved the file you need to enable the unit by running :

systemctl enable teamspeak

As a bonus, you can now use systemd to start, stop and reload your server by using

systemctl start teamspeak
systemctl stop teamspeak
systemctl reload teamspeak