作者: reistlin
来源: http://www.reistlin.com/blog/447
更新时间: 2024.03
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

azerothcore.gif

AzerothCore 主页:https://www.azerothcore.org
AzerothCore Wiki 文档:https://www.azerothcore.org/wiki/home

一,使用 screen 启动 worldserver

1、安装 screen:

apt-get install screen

2、使用 screen 启动 worldserver,窗口名称为:worldserver

cd /home/reistlin/azerothcore/bin
screen -S worldserver
./worldserver

3、退出当前 screen 窗口

Ctrl + a键 d键

4、查看 screen 窗口状态

reistlin@Debian:~/azerothcore/bin$ screen -ls
There is a screen on:
        112233.worldserver      (03/20/2024 10:00:00 AM)        (Attached)
1 Socket in /run/screen/S-reistlin.

二,使用 restart.sh 重启 AzerothCore

acore_screen:screen 窗口名称(默认:worldserver)
acore_path:AzerothCore 系统根目录(默认:/home/reistlin/azerothcore)
acore_delay:服务器计划重启时间,默认 60 秒后重启,同时通知所有在线玩家
app_user:运行 worldserver 的用户名称

#!/bin/bash
 
# name: restart AzerothCore by screen v0.1 (Linux Server)
# author: reistlin
# website: www.reistlin.com
# date: 2024.03.20
 
acore_screen="worldserver"
acore_path="/home/reistlin/azerothcore"
acore_delay="60"
 
app_user="reistlin"
app_process="SCREEN -S ${acore_screen}"
app_port="8085"
 
check1=`ps v -U ${app_user} | grep "${app_process}" | grep -v "grep" | wc -l`
check2=`netstat -nlpt | grep ":${app_port}" | wc -l`
 
if [ "${check1}" -eq 1 ] && [ "${check2}" -eq 1 ]; then
	# save
	screen -x -S ${acore_screen} -p 0 -X stuff "save\n"          
	sleep 1
 
	# shutdown
	screen -x -S ${acore_screen} -p 0 -X stuff "server shutdown ${acore_delay}\n"
	sleep `expr ${acore_delay} + 3`
 
	# start
	screen -x -S ${acore_screen} -p 0 -X stuff "${acore_path}/bin/worldserver\n"
	sleep 1
 
	# logfile
	echo "[`date "+%Y-%m-%d %H:%M:%S"`] ${acore_screen} service has successfully restarted" >> $HOME/crontab/restart.log
else
	echo "[EXIT] Not found worldserver by screen"
fi

编辑 crontab,设置每天凌晨 6 点自动重启

# restart AzerothCore worldserver
0  6 * * * /home/reistlin/crontab/restart.sh > /dev/null 2>&1

标签: azerothcore