fusen-gateway/run_gateway_latest.sh

48 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2023-11-13 09:52:02 +00:00
#! /bin/bash
2023-11-17 10:35:28 +00:00
rm ./gen/go -rf
2023-11-13 09:52:02 +00:00
./update_fspkg_master.sh
# 获取当前脚本的全局路径
script_path=$(realpath "$0")
# 获取当前脚本的目录
script_dir=$(dirname "$script_path")
cd $script_dir/proto
git pull origin master
cd $script_dir
go run -gcflags="-N" proto/goutils/proto_build/main.go gateway
run_server() {
server_name="server"
gateway_name="grpc-gateway"
# 导航到相应的目录
cd $script_dir/server
echo "build $gateway_name"
go build
# 如果之前存在相同名字的 screen 会话,先将其终止
# 首先尝试关闭已存在的screen会话
existing_session=$(screen -ls | grep -w "$gateway_name")
if [ -n "$existing_session" ]; then
echo "Terminating existing screen session for $gateway_name"
screen -S "$gateway_name" -X quit
while [[ $(screen -ls | grep "\.$gateway_name\s") ]]; do
sleep 0.1s # 等待0.1秒后再次检查
echo "wait for $gateway_name"
done
fi
# 循环检查screen进程是否存在
[ -f .gitignore ] || (echo "server" > .gitignore && echo "main" >> .gitignore)
# 使用 screen 运行 go run <server_name>.go
echo "Running $gateway_name"
screen -dmS $gateway_name -L ./$server_name
}
run_server