抑郁症健康,内容丰富有趣,生活中的好帮手!
抑郁症健康 > linux下编译mangos Linux下MANGOS服务端自动重启Shell启动脚本

linux下编译mangos Linux下MANGOS服务端自动重启Shell启动脚本

时间:2020-05-19 07:26:18

相关推荐

下面是一个Linux下支持的一个启动服务端的Shell代码。可以实现服务端当机后自动重新启动。

同时可以支持LINUX下用GDB对mangos进行当机调试,输出结果到crashes/Server.log??

你需要根据你的魔兽私服单机版在Linux中的路径调整下面的文件

#! /bin/bash

THIS_FULLPATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd -P)/`basename "${BASH_SOURCE[0]}"`

THIS_FOLDERPATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd -P)

APATH=/home/mangos/mangos-server/bin

WPATH=/home/mangos/mangos-server/bin

ASRV_BIN=realmd #This usually doesnt change. TrinityCore: authserverMaNGOS: realmdArcEmu: whocares?

WSRV_BIN_ORG=mangosd #This usually doesnt change. TrinityCore: worldserver MaNGOS: mangosd ArcEmu: whocares?

WSRV_BIN=mangosd

WSRV_SCR=mangosd

echo "run" > gdbcommands

echo "shell echo -e \" CRASHLOG BEGIN \"" >> gdbcommands

echo "info program" >> gdbcommands

echo "shell echo -e \" BACKTRACE \"" >> gdbcommands

echo "bt" >> gdbcommands

echo "shell echo -e \" BACKTRACE FULL \"" >> gdbcommands

echo "bt full" >> gdbcommands

echo "shell echo -e \" THREADS \"" >> gdbcommands

echo "info threads" >> gdbcommands

echo "shell echo -e \" THREADS BACKTRACE \"" >> gdbcommands

echo "thread apply all bt full" >> gdbcommands

DEBUG=false

#WORLD FUNCTIONS

startWorld()

{

if [ "$(screen -ls | grep $WSRV_SCR)" ]

then

echo $WSRV_BIN is already running

else

cd $WPATH

screen -AmdS $WSRV_SCR $THIS_FULLPATH $WSRV_BIN $DEBUG

echo $WSRV_BIN is alive

fi

}

restartWorld()

{

screen -S $WSRV_SCR -X stuff "saveall$(printf \ )"

echo saved all characters, and server restart initialized

screen -S $WSRV_SCR -X stuff "server restart 5$(printf \ )"

}

stopWorld()

{

screen -S $WSRV_SCR -X stuff "saveall

"

echo saveall sent, waiting 5 seconds to kill $WSRV_BIN

sleep 5

screen -S $WSRV_SCR -X kill &>/dev/null

echo $WSRV_BIN is dead

}

monitorWorld()

{

echo press ctrl+a+d to detach from the server without shutting it down

sleep 5

screen -r $WSRV_SCR

}

#AUTH FUNCTIONS

startAuth()

{

if [ "$(screen -ls | grep $ASRV_BIN)" ]

then

echo $ASRV_BIN is already running

else

cd $APATH

screen -AmdS $ASRV_BIN $THIS_FULLPATH $ASRV_BIN

echo $ASRV_BIN is alive

fi

}

stopAuth()

{

screen -S $ASRV_BIN -X kill &>/dev/null

echo $ASRV_BIN is dead

}

restartAuth()

{

stopAuth

startAuth

echo $ASRV_BIN restarted

}

monitorAuth()

{

echo press ctrl+a+d to detach from the server without shutting it down

sleep 5

screen -r $ASRV_BIN

}

#FUNCTION SELECTION

case "$1" in

$WSRV_BIN )

if [ "$2" == "true" ]

then

while x=1;

do

gdb $WPATH/$WSRV_BIN --batch -x gdbcommands | tee current

NOW=$(date +"%s-%d-%m-%Y")

mkdir -p $THIS_FOLDERPATH/crashes

mv current $THIS_FOLDERPATH/crashes/$NOW.log &>/dev/null

killall -9 $WSRV_BIN

echo $NOW $WSRV_BIN stopped, restarting! | tee -a $THIS_FULLPATH.log

echo crashlog available at: $THIS_FOLDERPATH/crashes/$NOW.log

sleep 1

done

else

while x=1;

do

./$WSRV_BIN

NOW=$(date +"%s-%d-%m-%Y")

echo $NOW $WSRV_BIN stopped, restarting! | tee -a $THIS_FULLPATH.log

sleep 1

done

fi

;;

$ASRV_BIN )

while x=1;

do

./$ASRV_BIN

NOW=$(date +"%s-%d-%m-%Y")

echo $NOW $ASRV_BIN stopped, restarting! | tee -a $THIS_FULLPATH.log

sleep 1

done

;;

"wstart" )

startWorld

;;

"wdstart" )

DEBUG=true

startWorld

;;

"wrestart" )

restartWorld

;;

"wstop" )

stopWorld

;;

"wmonitor" )

monitorWorld

;;

"astart" )

startAuth

;;

"arestart" )

restartAuth

;;

"astop" )

stopAuth

;;

"amonitor" )

monitorAuth

;;

"start" )

startWorld

startAuth

;;

"stop" )

stopWorld

stopAuth

;;

"restart" )

restartWorld

restartAuth

;;

* )

echo Your argument is invalid

echo "usage: start | stop | restart | wstart | wdstart | wrestart | wstop | wmonitor | astart | arestart | astop | amonitor"

exit 1

;;

esac

下面是完整代码下载

游客,如果您要查看本帖隐藏内容请回复

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

如果觉得《linux下编译mangos Linux下MANGOS服务端自动重启Shell启动脚本》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。