diff --git a/proxyserver/main.go b/proxyserver/main.go index a6e25325..745eb268 100644 --- a/proxyserver/main.go +++ b/proxyserver/main.go @@ -18,7 +18,6 @@ import ( "time" "github.com/gorilla/websocket" - "github.com/zeromicro/go-zero/core/logx" "gopkg.in/yaml.v2" _ "fusenapi/utils/auth" @@ -105,15 +104,16 @@ func main() { // 对/api开头的请求进行反向代理 proxy := httputil.NewSingleHostReverseProxy(apiURL) - proxy.ErrorHandler = func(res http.ResponseWriter, req *http.Request, err error) { - if err != nil { + // proxy.ErrorHandler = func(res http.ResponseWriter, req *http.Request, err error) { + // if err != nil { - // 在发生错误时进行处理 - logx.Error(err) - logx.Error(res.Header()) - res.WriteHeader(http.StatusNotFound) // 返回404状态码 - } - } + // // 在发生错误时进行处理 + // log.Println(res.Header()) + // logx.Info(err) + // logx.Info(res.Header()) + // res.WriteHeader(http.StatusNotFound) // 返回404状态码 + // } + // } proxy.ServeHTTP(w, r) return diff --git a/run_all_server.sh b/run_all_server.sh index 43723946..4d1b1580 100755 --- a/run_all_server.sh +++ b/run_all_server.sh @@ -8,22 +8,30 @@ go mod vendor # 定义一个函数来在每个服务器目录下运行 go run .go run_server() { server_name=$1 - echo "Running $server_name" - - + + # 导航到相应的目录 + cd server/$server_name + go build + echo "build $server_name" # 如果之前存在相同名字的 screen 会话,先将其终止 + # 首先尝试关闭已存在的screen会话 existing_session=$(screen -ls | grep -w "$server_name") if [ -n "$existing_session" ]; then echo "Terminating existing screen session for $server_name" 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 - # 导航到相应的目录 - cd server/$server_name - go build + + # 循环检查screen进程是否存在 [ -f .gitignore ] || echo $server_name > .gitignore # 使用 screen 运行 go run .go + + echo "Running $server_name" screen -dmS $server_name -L ./$server_name # 返回到上一级目录