chore: add patch for debug api,better workflow.

This commit is contained in:
gVisor bot 2023-01-30 17:00:02 +08:00
parent 2c25434b2e
commit 690fca467f
2 changed files with 64 additions and 12 deletions

View file

@ -63,17 +63,16 @@ jobs:
id: "8", id: "8",
} }
- { type: "WithCGO", target: "windows/*", id: "1" } - { type: "WithCGO", target: "windows/*", id: "1" }
- { type: "WithCGO", target: "linux/386,linux/amd64", id: "2" } - { type: "WithCGO", target: "linux/386", id: "2" }
- { type: "WithCGO", target: "linux/arm64,linux/riscv64", id: "3" } - { type: "WithCGO", target: "linux/amd64", id: "3" }
- { - { type: "WithCGO", target: "linux/arm64,linux/riscv64", id: "4" }
type: "WithCGO", - { type: "WithCGO", target: "linux/arm,", id: "5" }
target: "linux/arm,linux/arm-6,linux/arm-7", - { type: "WithCGO", target: "linux/arm-6,linux/arm-7", id: "6" }
id: "4", - { type: "WithCGO", target: "linux/mips,linux/mipsle", id: "7" }
} - { type: "WithCGO", target: "linux/mips64", id: "8" }
- { type: "WithCGO", target: "linux/mips,linux/mipsle", id: "5" } - { type: "WithCGO", target: "linux/mips64le", id: "9" }
- { type: "WithCGO", target: "linux/mips64,linux/mips64le", id: "6" } - { type: "WithCGO", target: "darwin-10.16/*", id: "10" }
- { type: "WithCGO", target: "darwin-10.16/*", id: "7" } - { type: "WithCGO", target: "android", id: "11" }
- { type: "WithCGO", target: "android", id: "8" }
steps: steps:
- name: Check out code into the Go module directory - name: Check out code into the Go module directory

53
patch/add_debug_api.patch Normal file
View file

@ -0,0 +1,53 @@
Subject: [PATCH] Chore: add debug api
---
Index: hub/route/debug.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/hub/route/debug.go b/hub/route/debug.go
new file mode 100644
--- /dev/null (revision df1007e2b14f7a526d176410995998bf06054657)
+++ b/hub/route/debug.go (revision df1007e2b14f7a526d176410995998bf06054657)
@@ -0,0 +1,21 @@
+package route
+
+import (
+ "github.com/Dreamacro/clash/log"
+ "github.com/go-chi/chi/v5"
+ "github.com/go-chi/chi/v5/middleware"
+ "net/http"
+ "runtime"
+)
+
+func debugRouter() http.Handler {
+ handler := middleware.Profiler()
+ r := chi.NewRouter()
+ r.Mount("/", handler)
+ r.Put("/gc", func(writer http.ResponseWriter, request *http.Request) {
+ log.Debugln("trigger GC")
+ runtime.GC()
+ })
+
+ return r
+}
Index: hub/route/server.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/hub/route/server.go b/hub/route/server.go
--- a/hub/route/server.go (revision f83fd6c690928ca7861196e3ca5af566303f95d5)
+++ b/hub/route/server.go (revision df1007e2b14f7a526d176410995998bf06054657)
@@ -59,6 +59,11 @@
MaxAge: 300,
})
r.Use(corsM.Handler)
+
+ r.Group(func(r chi.Router) {
+ r.Mount("/debug", debugRouter())
+ })
+
r.Group(func(r chi.Router) {
r.Use(authentication)
r.Get("/", hello)