Auto-restart?
#1

Would it be possible to fix an auto-restarter? I have this server hosted at a dedicated linux debian server in Denmark, and it crashes, completely randomly, and it's not coming back.. Is there an auto-restarter around? I don't know whether or not I posted in the right thread, please correct me if I didn't.

Thank you in advance,
Acid.
Reply
#2

Search the Wiki.
Reply
#3

Right there took me maybe 20 seconds. Here is the link for it


https://sampwiki.blast.hk/wiki/Linux_Server


The info you want is down by the bottom its called Keeping the Server Online
Reply
#4

I don't like to use a crond to keep my server up. so i found long time ago a pair of shell-scripts, that will keep your server up and running. You can use it not only with GTA but with some other servers also (i use it with UT2004 server also).

Script number 1, named startgtaserver.sh
Quote:

#!/bin/bash
cd /home/sampsvr
while [ true ]
do
cat /home/sampsvr/server_log.txt >> /home/sampsvr/gamelog.txt
./samp01b
done

This one goes near the server binary

Second script, named gtaserver:
Quote:

#!/bin/bash

server_start() {
/home/sampsvr/startgtaserver.sh & # put in full path and name of startup script
}

server_stop() {
killall startgtaserver.sh # your startup script name
killall samp01b # need to put in path to killall if its not in $PATH
}

server_restart() {
server_stop
sleep 1
server_start
}
case "$1" in
'start')
server_start
;;
'stop')
server_stop
;;
'restart')
server_restart
;;
*)
echo "usage $0 start|stop|restart"
esac

this one goes in /usr/local/bin

Just change paths in bouth scripts to yours, then you can start your server by typing
gtaserver start
stop server by typing
gtaserver stop
and finaly restart it by typing
gtaserver restart

the first script is responsible for keep your server up and running.
The second script is responsible for starting/stoping and restarting a server.

So, as you can see, no crond is involved.
And if you want your server to start automatically with your linux, put a line
gtaserver start
in your /etc/rc.d/rc.local , for example. (at least in System V -based os)

Hope it helps you

edited some typos and removed unnesessary coments from a script and named bouth scripts for better understanding.
Reply
#5

Thank you very much!
Reply
#6

Quote:
Originally Posted by Noosferatu
I don't like to use a crond to keep my server up. so i found long time ago a pair of shell-scripts, that will keep your server up and running. You can use it not only with GTA but with some other servers also (i use it with UT2004 server also).

Script number 1, named startgtaserver.sh
Quote:

#!/bin/bash
cd /home/sampsvr
while [ true ]
do
cat /home/sampsvr/server_log.txt >> /home/sampsvr/gamelog.txt
./samp01b
done

This one goes near the server binary

Second script, named gtaserver:
Quote:

#!/bin/bash

server_start() {
/home/sampsvr/startgtaserver.sh & # put in full path and name of startup script
}

server_stop() {
killall startgtaserver.sh # your startup script name
killall samp01b # need to put in path to killall if its not in $PATH
}

server_restart() {
server_stop
sleep 1
server_start
}
case "$1" in
'start')
server_start
;;
'stop')
server_stop
;;
'restart')
server_restart
;;
*)
echo "usage $0 start|stop|restart"
esac

this one goes in /usr/local/bin

Just change paths in bouth scripts to yours, then you can start your server by typing
gtaserver start
stop server by typing
gtaserver stop
and finaly restart it by typing
gtaserver restart

the first script is responsible for keep your server up and running.
The second script is responsible for starting/stoping and restarting a server.

So, as you can see, no crond is involved.
And if you want your server to start automatically with your linux, put a line
gtaserver start
in your /etc/rc.d/rc.local , for example. (at least in System V -based os)

Hope it helps you

edited some typos and removed unnesessary coments from a script and named bouth scripts for better understanding.
i need help with this. i don't know how to make it work. can somebody help me?
Reply
#7

Yea, I to need help with this. I have the files in the right place i believe.

> startgtaserver.sh in my samp server dir
> gtaserver in /usr/local/bin
Reply
#8


[root@iknowtechnology bin]# gtaserver start
-bash: gtaserver: command not found
[root@iknowtechnology bin]# sh gtaserver.sh start
: command not found2:
'taserver.sh: line 3: syntax error near unexpected token `{
'taserver.sh: line 3: `server_start() {
[root@iknowtechnology bin]#


WHATS THIS
Reply
#9

http://forum.sa-mp.com/index.php?topic=31833
^^ restarts every night and moves log to make way for new one

Theres also:

Код:
#!/bin/sh
cd /path/to/server
PROCESS_COUNT=$(ps -fu root | grep serverexe | grep -v grep | wc -l)
case $PROCESS_COUNT in
0) /path/to/server/serverexe &
;;
1) echo OK, program is running once 
;;
*) echo OK, program is already running multiple times 
;;
esac
^ make that something like checksamp.sh in your SAMP directory, and then use a 5 min cron job to run /path/to/server/checksamp.sh
Reply
#10

Modified restarter

Код:
#!/bin/bash
export GTA_PATH=/home/sampsvr #Modify with your path to sa-mp server
cd $GTA_PATH
while [ true ]; do
cat {$GTA_PATH}/server_log.txt >> {$GTA_PATH}/full_server_log.txt #Creating full server log
rm {$GTA_PATH}/server_log.txt #Deleting server.log In theory this will increase server performance
touch {$GTA_PATH}/server_log.txt #Creating an empty server.log
./samp022svr #Starting server
done
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)