Question Teamspeak autorestart on crash

Dibadu

Member
Joined
Nov 11, 2016
Messages
9
Points
35
Age
29
Hello im locking for a script what check every 5 seconds if the teamspeak server is online. When the script checks, that the teamspeak is offline it automaticly restart the server.

I found this:

Bash:
#!/bin/bash

TEAMSPEAK=`ps ax | grep ts3server_linux_amd64 | grep -v grep | wc -l`

if [ $TEAMSPEAK -eq 1 ]
then
exit
else
cd /path/to/teamspeak ; ./ts3server_startscript.sh start
fi

https://forum.teamspeak.com/threads/63810-Very-simple-server-auto-start-method-and-crash-restart-script-(root-amp-non-root)

but it didnt work on my server.
Im using Debian 9 64-Bit

I also found this theard:
https://r4p3.net/threads/teamspeak3-autorestart.3398/
but there is no answere

Please help me
 

Asphyxia

Server Monkey
Administrator
Joined
Apr 25, 2015
Messages
1,292
Points
252
Age
26
Location
North America
Hello im locking for a script what check every 5 seconds if the teamspeak server is online. When the script checks, that the teamspeak is offline it automaticly restart the server.

I found this:

Bash:
#!/bin/bash

TEAMSPEAK=`ps ax | grep ts3server_linux_amd64 | grep -v grep | wc -l`

if [ $TEAMSPEAK -eq 1 ]
then
exit
else
cd /path/to/teamspeak ; ./ts3server_startscript.sh start
fi

https://forum.teamspeak.com/threads/63810-Very-simple-server-auto-start-method-and-crash-restart-script-(root-amp-non-root)

but it didnt work on my server.
Im using Debian 9 64-Bit

I also found this theard:
https://r4p3.net/threads/teamspeak3-autorestart.3398/
but there is no answere

Please help me
Just use monit...

Code:
apt-get install monit
nano /etc/monit/monitrc
Replace all the config with:

Code:
## Start Monit in the background (run as a daemon):
#
  set daemon 30            # check services at 30 second intervals
   with start delay 10    # optional: delay the first check by 10 seconds (by
#                           # default Monit check immediately after Monit start)
          
  set logfile /var/log/monit.log
  set idfile /var/lib/monit/id
  set statefile /var/lib/monit/state
set mailserver mail.xxxxxxx.com              # primary mailserver
set mail-format { from: [email protected] }
set alert [email protected]



  set eventqueue
      basedir /var/lib/monit/events # set the base directory where events will be stored
      slots 100                     # optionally limit the queue size
## statement is missing::
## --8<--
set mail-format {
      from: [email protected]$HOST
   subject: monit alert --  $EVENT $SERVICE
   message: $EVENT Service $SERVICE

}
###

  check process ts3server with pidfile /home/ts3/ts3server.pid
    start program = "/home/ts3/ts3server_startscript.sh start" as uid ts3 and gid ts3
    stop program  = "/home/ts3/ts3server_startscript.sh stop" as uid ts3 and gid ts3

  
###############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#
   include /etc/monit/conf.d/*
#
Now restart monit!

Code:
/etc/init.d/monit stop
/etc/init.d/monit start
If ts3server.pid goes down, you get an email assuming you have email configured properly ;) edit the xxx.com stuff... and of course the process is relaunched.

Taken from https://forum.teamspeak.com/threads/83635-Restart-if-it-dies so I didn't have to configure.
 

Top