Forum

Results 1 to 7 of 7
  1. #1
    Join Date
    December 2009
    Location
    London, UK
    Posts
    10

    Starting the server automatically

    I used to run TS2 server on Linux previously, and I had a bash script that would detect whether or not TS was running and start it if it wasn't. This would be added to a crontab to be run automatically.

    Now TS3 is out, and there's a Mac version of the server (huzzah!!) has anyone written any scripts to start it automatically? It doesn't necessarily have to be a Mac specific script, I might be able to modify a Linux bash script.

    I tried modifying the old TS2 startup script, but I don't know much bash, and TS3 server doesn't use PID files, which was the way the old script detected if the server was running or not...

    I think if I knew how to accurately and reliably detect if a binary is running on OS X then I could probably hack something together.

    But like I said, my bash skills are less than desirable, so maybe someone else would have more luck.

  2. #2
    Join Date
    March 2009
    Location
    USA
    Posts
    20
    To my knowledge everything in this bash script works on mac as well as linux. This is the bash script I use for my teamspeak 3 server.

    make sure you change the DIR to the right location, the DAEMON to the correct file, and the PARAMS to anything you want to specify on commandline to it

    Code:
    #! /bin/sh
    
    # Leave this alone.
    NAME=teamspeak3_server
    
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    
    # DON'T FORGET TO CHANGE THE PATH TO YOUR NEEDS!
    DIR=/home/teamspeak_server
    
    # Change this to the file for your system.
    DAEMON=ts3server_linux_x86
    
    # Internet-server:
    PARAMS="inifile=ts3server.ini"
    
    # Leave this alone.
    DESC="Teamspeak server"
    
    case "$1" in
     start)
        ps aux | grep -v grep | grep "SCREEN -A -d -m -S $NAME" > /dev/null
        CHECK=$?
        if [ $CHECK -eq 0 ]; then
            echo "Teamspeak server is already running."
            exit 1
        else
            echo "Starting $DESC: $NAME"
            cd $DIR && screen -A -d -m -S $NAME ./$DAEMON $PARAMS
        fi
        ;;
    
     stop)
        if [[ `screen -ls |grep $NAME` ]]
           then
           echo -n "Stopping $DESC: $NAME"
           kill `ps aux | grep -v grep | grep "SCREEN -A -d -m -S $NAME" | awk '{print $2}'`
           echo " ... done."
        else
           echo "Coulnd't find a running $DESC"
        fi
        ;;
    
     status)
        ps aux | grep -v grep | grep "SCREEN -A -d -m -S $NAME" > /dev/null
        CHECK=$?
        if [ $CHECK -eq 0 ]; then
            echo "Teamspeak server running"
        else
            echo "Teamspeak server is not running"
        fi
        ;;
     *)
        echo "Usage: $0 {start|stop|status}"
        exit 1
        ;;
    esac
    
    exit 0
    Last edited by aeular; December 21st, 2009 at 04:53 AM.

  3. #3
    Join Date
    December 2009
    Location
    Germany
    Posts
    6
    you could just use Lingon to add teamspeak as a mac os x launchd service via a nice gui

  4. #4
    Join Date
    December 2009
    Location
    Dallas, TX, USA
    Posts
    23
    Agreed! Running through launchd is very preferable. I didn't know about Lingon. Thanks for the link. It takes all the fun out of making launchd services.
    Last edited by NerfYoda; December 21st, 2009 at 08:38 PM.

  5. #5
    Join Date
    December 2009
    Location
    London, UK
    Posts
    10
    For some reason if I try and start the ts3server_mac binary from anywhere but inside the directory it lives in, I get the error that it can't load the DB library and bails out.

    Do I need to copy the db library files into a location on my system or do I need to specify something on the command line when I launch the server to make it use the correct db library?

  6. #6
    Join Date
    December 2009
    Location
    Dallas, TX, USA
    Posts
    23
    Try setting LD_LIBRARY_PATH to your server's directory before you start it. If you're using that shell script then you may need to cd to that directory from within your screen session. Encapsulating that in a shell script should do the trick.

  7. #7
    Join Date
    December 2009
    Location
    London, UK
    Posts
    10
    Setting that variable definitely helped. Now I'm getting

    Code:
    2009-12-22 06:14:55.050314|CRITICAL|DatabaseQuery |   | setSQLfromFile( file:sql/create_sqlite/create_tables.sql) failed
    I imagine that's because I'll need to specify the paths to those sql scripts on the command line. I'll put that stuff in an ini and pass that in...

    Thanks Guys!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Server is going down automatically?
    By tomtom00 in forum Windows
    Replies: 12
    Last Post: May 23rd, 2012, 11:07 AM
  2. The server log me out automatically
    By KiCKFLiP in forum Server Support
    Replies: 4
    Last Post: April 30th, 2011, 08:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •