diff --git a/go.mod b/go.mod index 3309356..066d4e1 100644 --- a/go.mod +++ b/go.mod @@ -49,3 +49,6 @@ require ( ) replace fusen-basic v0.0.0 => gitee.com/fusenpack/fusen-basic v0.0.5-0.20231124072222-16de191b1dbe + + +replace fusen-model v0.0.0 => gitee.com/fusenpack/fusen-model v0.0.1 \ No newline at end of file diff --git a/run_latest.sh b/run_latest.sh new file mode 100755 index 0000000..b44ec80 --- /dev/null +++ b/run_latest.sh @@ -0,0 +1,58 @@ +#! /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 \ No newline at end of file