feat(server): 添加数据库和网关服务脚本并更新 Docker 配置
- 新增 DBServer 和 Gateway 的启动和停止脚本 - 更新 docker-compose.yml,添加 db 和 gate 服务 - 优化服务启动顺序,确保 db 服务先于 logic 和 gate 服务启动
This commit is contained in:
11
DBServer/start.sh
Normal file
11
DBServer/start.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd $(cd "$(dirname "$0")" && pwd)
|
||||||
|
path=`pwd`
|
||||||
|
./stop.sh
|
||||||
|
|
||||||
|
echo "======================【启动】========================"
|
||||||
|
datetime=`date "+%Y-%m-%d.%H:%M:%S"`
|
||||||
|
|
||||||
|
echo "["$datetime"] 正在启动 DB 服务器 [dbserver_r]..."
|
||||||
|
|
||||||
|
$path/dbserver_r $path/DBServerLinux.txt
|
||||||
32
DBServer/stop.sh
Normal file
32
DBServer/stop.sh
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
path=`pwd`
|
||||||
|
srv = "dbserver"
|
||||||
|
|
||||||
|
datetime=`date "+%Y-%m-%d.%H:%M:%S"`
|
||||||
|
curdoc=$(pwd|awk -F \/ '{print $NF}')
|
||||||
|
|
||||||
|
|
||||||
|
pid=`ps aux |grep $path|grep $srv|grep -v grep|grep "\<$curdoc\>"|grep -v "/bin/bash"|awk '{print $2}'`
|
||||||
|
if [[ -n $pid ]]; then
|
||||||
|
echo "开始结束服务器: $srv (pid=$pid)"
|
||||||
|
kill -15 $pid
|
||||||
|
NUM=10
|
||||||
|
while true; do
|
||||||
|
datetime=`date "+%Y-%m-%d.%H:%M:%S"`
|
||||||
|
proc=`ps aux |grep $path|grep $srv|grep -v grep|grep "\<$curdoc\>"|grep -v "/bin/bash"|wc -l`
|
||||||
|
if [ $proc == 0 ];
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ $NUM -lt 0 ];
|
||||||
|
then
|
||||||
|
kill -9 $pid
|
||||||
|
echo $datetime" 游戏服务 "$path" "$srv" 强制结束"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo $datetime" 游戏服务 "$path" "$srv" 结束中..."
|
||||||
|
sleep 1
|
||||||
|
let NUM--
|
||||||
|
done
|
||||||
|
echo "已结束服务器: $srv"
|
||||||
|
fi
|
||||||
11
Gateway/start.sh
Normal file
11
Gateway/start.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd $(cd "$(dirname "$0")" && pwd)
|
||||||
|
path=`pwd`
|
||||||
|
./stop.sh
|
||||||
|
|
||||||
|
echo "======================【启动】========================"
|
||||||
|
datetime=`date "+%Y-%m-%d.%H:%M:%S"`
|
||||||
|
|
||||||
|
echo "["$datetime"] 正在启动 Logic 服务器 [gateway_r]..."
|
||||||
|
|
||||||
|
$path/gateway_r $path/GateWay.txt
|
||||||
32
Gateway/stop.sh
Normal file
32
Gateway/stop.sh
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
path=`pwd`
|
||||||
|
srv = "gateway"
|
||||||
|
|
||||||
|
datetime=`date "+%Y-%m-%d.%H:%M:%S"`
|
||||||
|
curdoc=$(pwd|awk -F \/ '{print $NF}')
|
||||||
|
|
||||||
|
|
||||||
|
pid=`ps aux |grep $path|grep $srv|grep -v grep|grep "\<$curdoc\>"|grep -v "/bin/bash"|awk '{print $2}'`
|
||||||
|
if [[ -n $pid ]]; then
|
||||||
|
echo "开始结束服务器: $srv (pid=$pid)"
|
||||||
|
kill -15 $pid
|
||||||
|
NUM=10
|
||||||
|
while true; do
|
||||||
|
datetime=`date "+%Y-%m-%d.%H:%M:%S"`
|
||||||
|
proc=`ps aux |grep $path|grep $srv|grep -v grep|grep "\<$curdoc\>"|grep -v "/bin/bash"|wc -l`
|
||||||
|
if [ $proc == 0 ];
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ $NUM -lt 0 ];
|
||||||
|
then
|
||||||
|
kill -9 $pid
|
||||||
|
echo $datetime" 游戏服务 "$path" "$srv" 强制结束"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo $datetime" 游戏服务 "$path" "$srv" 结束中..."
|
||||||
|
sleep 1
|
||||||
|
let NUM--
|
||||||
|
done
|
||||||
|
echo "已结束服务器: $srv"
|
||||||
|
fi
|
||||||
@@ -1,24 +1,24 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
server:
|
db:
|
||||||
image: chuanqi-os:latest
|
image: chuanqi-os:latest
|
||||||
container_name: chuanqi-server-dev
|
container_name: chuanqi-server-db
|
||||||
cpus: '2'
|
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
volumes:
|
volumes:
|
||||||
- .:/data/server/s1
|
- ./DBServer:/data/server/s1/DBServer
|
||||||
- ./wch:/etc/yum/wch
|
- ./wch:/etc/yum/wch
|
||||||
entrypoint: "/data/server/s1/run.sh"
|
entrypoint: "/data/server/s1/DBServer/start.sh"
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
TZ: Asia/Shanghai
|
TZ: Asia/Shanghai
|
||||||
|
|
||||||
logic:
|
logic:
|
||||||
image: chuanqi-os:latest
|
image: chuanqi-os:latest
|
||||||
container_name: chuanqi-server-logic
|
container_name: chuanqi-server-logic
|
||||||
cpus: '4'
|
depends_on:
|
||||||
cpuset: '13,14,15,16'
|
- db # 等待db服务启动
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
volumes:
|
volumes:
|
||||||
- ./LogicServer:/data/server/s1/LogicServer
|
- ./LogicServer:/data/server/s1/LogicServer
|
||||||
@@ -28,3 +28,18 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
TZ: Asia/Shanghai
|
TZ: Asia/Shanghai
|
||||||
|
|
||||||
|
gate:
|
||||||
|
image: chuanqi-os:latest
|
||||||
|
container_name: chuanqi-server-gate
|
||||||
|
depends_on:
|
||||||
|
- logic # 等待logic服务启动
|
||||||
|
stdin_open: true
|
||||||
|
volumes:
|
||||||
|
- ./GateServer:/data/server/s1/GateServer
|
||||||
|
- ./wch:/etc/yum/wch
|
||||||
|
entrypoint: "/data/server/s1/GateServer/start.sh"
|
||||||
|
network_mode: "host"
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
Reference in New Issue
Block a user