26.01.2015, 01:38
Maintaining a server and keeping it online:
Dealing with attacks:
When your server is under attack you'll be forced to do something about it. The first thing I'd do is contact your host, and ask them for detailed information regarding the attack. If it's just a small dos-type attack coming from one specific person / IP it can usually be instantly blocked and stopped.
This isn't always the case, and while no host can offer 100% ddoss protection, there are many options for preventing, and stopping attacks as they begin. The first step would be to find a fast and responsive host with staff that can adjust things as needed within minutes.
Automatically starting your server after crashes, and other things that can stop your server:
In linux, - there are many easy scripts that can run the server if it's not actively running. On windows, this may be a little harder to come by - so I won't go in depth regarding that.
For linux, there are many options, and since wiki has a few of them I'll quote them:
Launching your server
Windows
On windows, launching your server is as easy as running samp-server.exe. You may be prompted to run as administrator when running the server. And that's basically it!
Now linux is a different story.
Basically, we have a few options for launching, and running our server. I would highly derecommend this method as it closes the session, and stops the server after the active session has ended. How-ever it can be useful for quick debugging / development purposes.
Basically, just type
And the process will start.
Our next method will start the app as a background, and will output the processID. Additionally, - startup data can generally befound within a nohup file in the server directory. The server will remain online even after the session is closed.
Simply:
Server Log
Almost everything that happens within a SA-MP server is logged to a file called "server_log.txt". This should be inside the main directory of the server. Note that if this file is readonly, the server will crash.
And that's it! If you have any problems starting the server, try ****** and if that doesn't help simply post in the server support or scripting help section(s) accordingly.
Thats all for now, hopefully you found this somewhat useful... I really don't want to make this too long, so I guess this is a good way to end it.
Bye.
Dealing with attacks:
When your server is under attack you'll be forced to do something about it. The first thing I'd do is contact your host, and ask them for detailed information regarding the attack. If it's just a small dos-type attack coming from one specific person / IP it can usually be instantly blocked and stopped.
This isn't always the case, and while no host can offer 100% ddoss protection, there are many options for preventing, and stopping attacks as they begin. The first step would be to find a fast and responsive host with staff that can adjust things as needed within minutes.
Automatically starting your server after crashes, and other things that can stop your server:
In linux, - there are many easy scripts that can run the server if it's not actively running. On windows, this may be a little harder to come by - so I won't go in depth regarding that.
For linux, there are many options, and since wiki has a few of them I'll quote them:
Quote:
Originally Posted by SAMP WIKI
Keeping the Server Online
With limited anti-crash options available in the SA-MP Server, there is a large possibility of receiving Segmentation Faults or any other error generated by your (Pawn) gamemode. This will shutdown the server, and you'll have to start it up yourself again. Method 1 All you need to use the program below is a Linux environment, and the possibility to use cron. This program will check if the samp03svr process is running, and if it isn't, start it up again. You'll need to install the following crontab: */1 * * * * /path/to/samp/checksamp.sh >/dev/null 2>&1 Help about using crontab can be found here. checksamp.sh: #!/bin/sh PROCESS_COUNT=$(ps -fu root | grep samp03svr | grep -v grep | wc -l) case $PROCESS_COUNT in 0) /path/to/samp03svr & ;; 1) #OK, program is already running once ;; *) #OK, program is already multiple times ;; esac Make sure that you have to correct paths set up, the script won't work if you haven't. The script is currently unable to handle multiple SA-MP Servers on the same machine, but works perfectly when there is only one running/needed. You need to chmod the checksamp.sh file to 0755 (+x)! Method 2 If you don't want to use crontab and if you want to have server log saved to a separate directory on server crash you can use this script. To keep your server online using this script, first you need to stop your server and then execute it with this command: nohup ./restart.sh & restart.sh: #!/bin/sh log=samp.log dat=`date` samp="/path/to/samp/server/samp03svr" cd /path/to/samp/server echo "${dat} watchdog script starting." >>${log} while true; do echo "${dat} Server exited, restarting..." >>${log} mv /path/to/samp/server/server_log.txt /path/to/samp/server/logs/server_log.`date '+%m%d%y%H%M%S'` ${samp} >> $log sleep 2 done This method will bring your server back up whenever it crashes or when the RCON exit command is issued. It will also save the server log into a separate directory. Method 3 You can also restart the server using this pair of shell scripts. Assumed is that the server is located in the /home/sampsvr directory. Script number 1 startgtaserver.sh: #!/bin/bash export GTA_PATH=/home/sampsvr cd $GTA_PATH while [ true ]; do cat {$GTA_PATH}/server_log.txt >> {$GTA_PATH}/full_server_log.txt rm {$GTA_PATH}/server_log.txt touch {$GTA_PATH}/server_log.txt ./samp03svr done This one goes near the server binary. Second script, named gtaserver.sh: #!/bin/bash server_start() { screen /home/sampsvr/startgtaserver.sh & # put in full path and name of startup script } server_stop() { killall startgtaserver.sh # your startup script name killall samp03svr # 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 Place the script in /usr/local/bin/. Just change paths in both scripts to yours, then you can start your server by typing gtaserver start, stop server by typing gtaserver stop, and finally restart it by typing gtaserver restart. Make sure the scripts are executable. |
Windows
On windows, launching your server is as easy as running samp-server.exe. You may be prompted to run as administrator when running the server. And that's basically it!
Now linux is a different story.
Basically, we have a few options for launching, and running our server. I would highly derecommend this method as it closes the session, and stops the server after the active session has ended. How-ever it can be useful for quick debugging / development purposes.
Basically, just type
Code:
./samp03svr
Our next method will start the app as a background, and will output the processID. Additionally, - startup data can generally befound within a nohup file in the server directory. The server will remain online even after the session is closed.
Simply:
Code:
nohup ./samp03svr
Almost everything that happens within a SA-MP server is logged to a file called "server_log.txt". This should be inside the main directory of the server. Note that if this file is readonly, the server will crash.
And that's it! If you have any problems starting the server, try ****** and if that doesn't help simply post in the server support or scripting help section(s) accordingly.
Thats all for now, hopefully you found this somewhat useful... I really don't want to make this too long, so I guess this is a good way to end it.
Bye.