AAO25.com
Assist => Support => Server Support => Topic started by: Kuschizzza on Thursday, April 10, 2014, 16:39:28 PM
-
Hello Guys,
I need a server restart script for my americas army server. It should automatically restart my server if my "root server are going for reboot or something" and restart after crash.
Is it possible to get it from someone? It's for Linux (Debian)
Thanks a lot !
-
sorry, i made them only for windows.
-
damn I need it for Debian
-
Have you tried an expert debian forum? I bet they might have solution for that. Try googling.
-
You have to lear about Linux Standard Base init scripts:
https://wiki.debian.org/LSBInitScripts (https://wiki.debian.org/LSBInitScripts)
http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/tocsysinit.html (http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/tocsysinit.html)
Show code that you will write.
-
Hello Guys,
I need a server restart script for my americas army server. It should automatically restart my server if my "root server are going for reboot or something" and restart after crash.
Is it possible to get it from someone? It's for Linux (Debian)
Thanks a lot !
fyi
if you do decide to issue a start command in the rc3.d directory (as a link to init.d), then you need to serious consider what system commands you use, as there could be security issues.
I'd opt for crontab as a user that only has access to the 25Assist binary, cron'd every two minutes that check the server and then restarts it if the server binary is missing.
OIC!
-
For anyone that runs linux servers.
This assumes you know about sysV init styles and bash shells. I don't guarantee this to work (mine actually have a lot more stuff) but it should give you some ideas for creating your own scripts. I run multiple servers (naming scheme armyops25_1, armyops25_2, ect) and have multiple /etc/init.d startup scripts for each. Make sure you configure them to run at boot (chkconfig --add). This is from redhat/centos. I don't know if Debian uses a source function include file (. /etc/rc.d/init.d/functions) or not nor do I know if the latest distros still use SysV style (/etc/init.d, /etc/rc.d, chkconfig, ect.) init scripts.
#!/bin/bash
#
# chkconfig: 345 73 73
# description: Starts ArmyOps server
# Source function library.
. /etc/rc.d/init.d/functions
#procid=$$
# wherever you store the assist folder for each game. Some things can be soft linked if you are space conscious
[ -f /usr/local/bin/armyops25_1/System/server-bin ] || exit 0
prog="/usr/local/bin/armyops25_1/System/server-bin"
rport=1948
args="GLOBAL Pipeline_SF "
timestamp=$(date +"%m%d%y-%H%M")
RETVAL=0
# See how we were called.
case "$1" in
start)
cd /usr/local/bin/armyops25_1/System
#save previous log. Use a logrotate cron if you need to
cp aa25.log Logs/armyops25_1-aa25.log.$timestamp
cp aa25srv.log Logs/armyops25_1-aa25srv.log.$timestamp
echo -n "Starting ArmyOps Server 1 on port $rport: "
$prog $args>/dev/null 2>&1 &
sleep 1
procid=$( pidof -s /usr/local/bin/armyops25_1/System/server-bin )
if [ $procid ]
then
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/armyops25_1
echo_success
echo
echo $procid > /var/run/armyops25_1.pid
#give cpu priority to servers if you need to
renice -1 $procid >/dev/null 2>&1
procid=$( pidof -s /usr/local/bin/armyops25_1/System/serverx )
renice -1 $procid >/dev/null 2>&1
else
echo_failure
fi
;;
stop)
echo -n "Stopping ArmyOps Server 1: "
procid=`pgrep -f wtport=9023`
if [[ $procid ]]
then
kill $procid
fi
# kill the three armyops25 processes
procid=`pgrep -f '/usr/local/bin/armyops25_1/System/server-bin'`
if [[ $procid ]]
then
kill -9 $procid
unset -v procid
fi
procid=`pgrep -f LD_LIBRARY_PATH=/usr/local/bin/armyops25_1`
if [[ $procid ]]
then
kill -9 $procid
unset -v procid
fi
procid=`pgrep -f /usr/local/bin/armyops25_1/System/serverx`
if [[ $procid ]]
then
kill -9 $procid
unset -v procid
fi
[ $RETVAL -eq 0 ] && rm -f /var/run/armyops25_1.pid
if [ $RETVAL -eq 0 ]
then
echo_success
echo
else
echo_failure
echo
fi
;;
restart|reload)
$0 stop
sleep 5
$0 start
RETVAL=$?
;;
*)
echo "Usage: armyops {start|stop|restart}"
exit 1
esac
exit $RETVAL