1

Topic: Server Script

Hello SALAD here, I was wondering if there was somebody here who could help me out. I need a script for my vps that is running on linux. things that i need it to do are: Start the server, Reset the server when it crashes, and  link to the config file. Thank you.

-SALAD

2

Re: Server Script

http://87.106.248.229/files/
start & server.sh

In start.sh you have to edit your settings. make a user with useradd and give him pw with passwd user
Configs in folder config prefixX.cfg | X is the number of the server.
Everything stands in start.sh

3

Re: Server Script

Ok, so when there are these, {} do i edit it so there is none example: {PWD} = mypassword

-SALAD

4

Re: Server Script

Hey Salad, you are looking for something like this...

#!/bin/bash
# serverscript.sh

(
# Inside parenthese, and therefore a subshell
while [ 1 ]   # Endless loop
do
  echo "Teeworlds Server started..."
  ./teeworlds_srv -f defaultserver.txt
done
)

exit $?  # End of script but will never get here

And then you proceed to run the script in the directory with...

sh serverscript.sh

Not sure why Botox suggests adding a user and multiple script files, etc. The script above will never end unless you kill the process. Every time teeworlds crashes it loops back up and starts it again with the config file you provided.

5 (edited by SALAD 2011-03-04 08:59:54)

Re: Server Script

Thank you Nilaya, I also need the server to run in the background so I can close putty and it will still be running. PS - I love your signature. [offtopic] Do you watch swedish mealtime? big_smile [/offtopic]

-SALAD

6

Re: Server Script

 sh serverscript.sh &

The ampersand at the end runs the script in the background.

7

Re: Server Script

can you tell me characterstic of your vps? i am interesting to a one, where did you buy it? How many teeworlds server can you run without lags?

8

Re: Server Script

well i run located in the usa and you barely need any ram (maybe 512 mb to run 10 teeworlds servers without lag) the previous vps i had had 512 mb and i ran around 10 servers. it cost 25 USD a month. also bandwidth and storage space dont matter so much for teeworlds servers so dont worry about them. make sure to get a server located close to you so you can have a good ping at it. to find vps's just search "buy a vps {where you live}"

-SALAD

9

Re: Server Script

i found this at 9 EUR/month: Intel Xeon Quad Core only 1 core cpu, RAM 256MB SWAP 256MB, hard disk space 10GB,
Backup, control Panel VPS, Remote restart, Console VPS, Band width [5 Mbps flat ] or [100 Mbps, max 200GB/month]    ,
operative system any you like of th linux version (Ubunti Debian CentOS Gentoo OpenSuse Fedora)-> 32 or 64 bit

it is good or need more?

10

Re: Server Script

I think you could find one for cheaper but that seems to be reasonable. I think that you will be able to run 3-6 servers on that. If you run windows then you will need to download and learn putty.

-SALAD

11

Re: Server Script

Nilaya, also I need a way to run more than one server with that script, it wont let me as it is.

-SALAD

12

Re: Server Script

thanks for your experience, i think will choose linux CentOS 5.5 with 100 Mbps (limited to 200GB/month), can you give me a guide specific for running Teeworlds on a linux Vps?

13

Re: Server Script

Sorry Salad, I'm not familiar enough with Bash to do something like that. Couldn't you just have a separate script for each server? You will only have to run them once anyway.

14

Re: Server Script

well when i run 1 I have to press ctrl+c to put in another command and that makes it so the previoust script shuts down.

-SALAD

15

Re: Server Script

No, if you use that ampersand at the end of the command just press enter and you get the terminal back and the server will be running in the background.

16

Re: Server Script

OHH
lol

-SALAD

17 (edited by Deleted User 2011-03-08 02:04:00)

Re: Server Script

The script of Nilaya has the problem that it will waste much cpu power with the endless loop. If your server is using upstart you can even use such a script. It can all things that you want.

18

Re: Server Script

How would I fix the script so it wouldnt eat up so much cpu power?

-SALAD

19

Re: Server Script

What are you talking about sworddragon? It does not eat up cpu power. Run a top command and see for yourself. What happens is after it executes the teeworlds server it merely sits idle until that process is terminated. Only once it has been terminated will it loop back up and start a new teeworlds server.

20 (edited by Deleted User 2011-03-09 01:21:53)

Re: Server Script

I haven't tested your script as I posted this. But I have done this now and your right. But I still prefer the upstart way. No running bash process in the background and some more features.

21

Re: Server Script

seems you need some quick and dirty thing...

#!/bin/sh
while true;do
./teeworlds_srv -f config.cfg
done

works without much cpu/ram usage smile

Remember me? Questions? Just leave a message, I will respond within 72 hrs!

22 (edited by fisted 2011-03-23 15:18:17)

Re: Server Script

#!/bin/bash
cd ~/twsrv
c=100 #restart this many times before giving up
echo invoke at $(date) >> launchlog
while [ $c -ne 0 ]; do
        echo will launch at $(date) >> launchlog
        unlink srvlog_latest || true
        LOGFILE=srvlog_$(date +%s)
        touch $LOGFILE
        ln -s $LOGFILE srvlog_latest
        ./teeworlds_srv -f myserver.cfg &> $LOGFILE
        echo terminated at $(date) >> launchlog
        c=$(($c - 1))
done
echo giving up at $(date) >> launchlog

my two cents.. this is what i usually run, within a screen session. (note that i'm not that comfortable with bash scripting)

23

Re: Server Script

Run with 1_dm.sh

1_dm.sh:

#!/bin/sh

./do_screen.sh dm

do_screen.sh:

#!/bin/sh

screen -AmdS tw_$1 ./do_start.sh $1
sleep 1
screen -d -r tw_$1

do_start.sh:

#!/bin/sh

while true;
    do ./teeworlds_srv -s -f $1.cfg;
    sleep 1; 
done;

Download example: teeworlds.su/downloads/mods/example.zip

24 (edited by UnoSkorpion 2012-02-19 20:21:54)

Re: Server Script

if you start server in terminal, after closing terminal server will stop. you need add key in scriptfile "&"

./teeworlds_srv -f folder_for_cfgs/yourconfig.cfg >folder_for_logs/teeworlds_srv.log &

after closing terminal, your server will not  stop wink

25 (edited by GBKing 2012-02-19 22:14:37)

Re: Server Script

Hello Salad and everyone else, I needed the same thing as you and wrote some scripts myself. You can download and read the instructions here:
http://www.teeworlds.com/forum/viewtopic.php?id=8613
The scripts are very resource friendly, do all you described above that you need and are friendly to use.