Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-09-22 11:36:16 +08:00
commit 2a849dde38
2 changed files with 23 additions and 15 deletions

View File

@ -18,7 +18,6 @@ import (
"time" "time"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/zeromicro/go-zero/core/logx"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
_ "fusenapi/utils/auth" _ "fusenapi/utils/auth"
@ -105,15 +104,16 @@ func main() {
// 对/api开头的请求进行反向代理 // 对/api开头的请求进行反向代理
proxy := httputil.NewSingleHostReverseProxy(apiURL) proxy := httputil.NewSingleHostReverseProxy(apiURL)
proxy.ErrorHandler = func(res http.ResponseWriter, req *http.Request, err error) { // proxy.ErrorHandler = func(res http.ResponseWriter, req *http.Request, err error) {
if err != nil { // if err != nil {
// 在发生错误时进行处理 // // 在发生错误时进行处理
logx.Error(err) // log.Println(res.Header())
logx.Error(res.Header()) // logx.Info(err)
res.WriteHeader(http.StatusNotFound) // 返回404状态码 // logx.Info(res.Header())
} // res.WriteHeader(http.StatusNotFound) // 返回404状态码
} // }
// }
proxy.ServeHTTP(w, r) proxy.ServeHTTP(w, r)
return return

View File

@ -8,22 +8,30 @@ go mod vendor
# 定义一个函数来在每个服务器目录下运行 go run <server_name>.go # 定义一个函数来在每个服务器目录下运行 go run <server_name>.go
run_server() { run_server() {
server_name=$1 server_name=$1
echo "Running $server_name"
# 导航到相应的目录
cd server/$server_name
go build
echo "build $server_name"
# 如果之前存在相同名字的 screen 会话,先将其终止 # 如果之前存在相同名字的 screen 会话,先将其终止
# 首先尝试关闭已存在的screen会话
existing_session=$(screen -ls | grep -w "$server_name") existing_session=$(screen -ls | grep -w "$server_name")
if [ -n "$existing_session" ]; then if [ -n "$existing_session" ]; then
echo "Terminating existing screen session for $server_name" echo "Terminating existing screen session for $server_name"
screen -S "$server_name" -X quit screen -S "$server_name" -X quit
while [[ $(screen -ls | grep "\.$server_name\s") ]]; do
sleep 0.1s # 等待0.1秒后再次检查
echo "wait for $server_name"
done
fi fi
# 导航到相应的目录
cd server/$server_name # 循环检查screen进程是否存在
go build
[ -f .gitignore ] || echo $server_name > .gitignore [ -f .gitignore ] || echo $server_name > .gitignore
# 使用 screen 运行 go run <server_name>.go # 使用 screen 运行 go run <server_name>.go
echo "Running $server_name"
screen -dmS $server_name -L ./$server_name screen -dmS $server_name -L ./$server_name
# 返回到上一级目录 # 返回到上一级目录