proto/goutils/proto_build/tpls/run_latest.tpl
huangsimin@fusen.cn c0cbff775f 最新版本
2023-11-27 17:36:02 +08:00

58 lines
1.5 KiB
Smarty
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#! /bin/bash
# 获取当前脚本的全局路径
script_path=$(realpath "$0")
# 获取当前脚本的目录
script_dir=$(dirname "$script_path")
# 执行更新最新的包
$script_dir/update_fspkg_master.sh
# 拼接service_config.ini的路径
config_file="$script_dir/server/service_config.ini"
# 检查文件是否存在
if [[ ! -f "$config_file" ]]; then
echo "Error: service_config.ini 文件不存在"
exit 1
fi
echo "read $config_file"
service_name=$(grep "SERVICE_NAME=" $config_file | cut -d'=' -f2 | cut -d' ' -f1)
# 输出变量值
echo "service name: $service_name"
cd $script_dir/proto
git pull origin master
cd $script_dir
go run -gcflags="-N" proto/goutils/proto_build/main.go
run_server() {
#
cd $script_dir/server
echo "build $service_name"
go build -o $service_name
# screen
# screen会话
existing_session=$(screen -ls | grep -w "$service_name")
if [ -n "$existing_session" ]; then
echo "Terminating existing screen session for $service_name"
screen -S "$service_name" -X quit
while [[ $(screen -ls | grep "\.$service_name\s") ]]; do
sleep 0.1s # 0.1
echo "wait for $service_name"
done
fi
# screen进程是否存在
[ -f .gitignore ] || (echo "server" > .gitignore && echo "$service_name" >> .gitignore && echo "main" >> .gitignore)
echo "Running $service_name"
screen -dmS $service_name -L ./$service_name
}
run_server