From db7d53532a406bf5cd475a2536f714dd7b03aa14 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Fri, 22 Sep 2023 11:27:19 +0800 Subject: [PATCH 1/4] nacos config --- run_all_server.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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 # 返回到上一级目录 From a6a40a2ad5ccd0448d47690acfc035e41fad0e35 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Fri, 22 Sep 2023 11:31:39 +0800 Subject: [PATCH 2/4] nacos config --- proxyserver/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/proxyserver/main.go b/proxyserver/main.go index a6e25325..e271f6c9 100644 --- a/proxyserver/main.go +++ b/proxyserver/main.go @@ -109,6 +109,7 @@ func main() { if err != nil { // 在发生错误时进行处理 + log.Println(res.Header()) logx.Error(err) logx.Error(res.Header()) res.WriteHeader(http.StatusNotFound) // 返回404状态码 From e925d8c6841d81582ef59400d40a189fb1d21f23 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Fri, 22 Sep 2023 11:32:16 +0800 Subject: [PATCH 3/4] nacos config --- proxyserver/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxyserver/main.go b/proxyserver/main.go index e271f6c9..a4a2da96 100644 --- a/proxyserver/main.go +++ b/proxyserver/main.go @@ -110,8 +110,8 @@ func main() { // 在发生错误时进行处理 log.Println(res.Header()) - logx.Error(err) - logx.Error(res.Header()) + logx.Info(err) + logx.Info(res.Header()) res.WriteHeader(http.StatusNotFound) // 返回404状态码 } } From 2d224c0d67f4e2b8430c92d79a08c24495a2241f Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Fri, 22 Sep 2023 11:35:40 +0800 Subject: [PATCH 4/4] nacos config --- proxyserver/main.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/proxyserver/main.go b/proxyserver/main.go index a4a2da96..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,16 +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 { - // 在发生错误时进行处理 - log.Println(res.Header()) - logx.Info(err) - logx.Info(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