Signed-off-by: Derek McGowan <derek@mcg.dev>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,53 +0,0 @@ |
| 1 |
-package debug |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "context" |
|
| 5 |
- "expvar" |
|
| 6 |
- "net/http" |
|
| 7 |
- "net/http/pprof" |
|
| 8 |
- |
|
| 9 |
- "github.com/docker/docker/api/server/httputils" |
|
| 10 |
- "github.com/docker/docker/api/server/router" |
|
| 11 |
-) |
|
| 12 |
- |
|
| 13 |
-// NewRouter creates a new debug router |
|
| 14 |
-// The debug router holds endpoints for debug the daemon, such as those for pprof. |
|
| 15 |
-func NewRouter() router.Router {
|
|
| 16 |
- r := &debugRouter{}
|
|
| 17 |
- r.initRoutes() |
|
| 18 |
- return r |
|
| 19 |
-} |
|
| 20 |
- |
|
| 21 |
-type debugRouter struct {
|
|
| 22 |
- routes []router.Route |
|
| 23 |
-} |
|
| 24 |
- |
|
| 25 |
-func (r *debugRouter) initRoutes() {
|
|
| 26 |
- r.routes = []router.Route{
|
|
| 27 |
- router.NewGetRoute("/debug/vars", frameworkAdaptHandler(expvar.Handler())),
|
|
| 28 |
- router.NewGetRoute("/debug/pprof/", frameworkAdaptHandlerFunc(pprof.Index)),
|
|
| 29 |
- router.NewGetRoute("/debug/pprof/cmdline", frameworkAdaptHandlerFunc(pprof.Cmdline)),
|
|
| 30 |
- router.NewGetRoute("/debug/pprof/profile", frameworkAdaptHandlerFunc(pprof.Profile)),
|
|
| 31 |
- router.NewGetRoute("/debug/pprof/symbol", frameworkAdaptHandlerFunc(pprof.Symbol)),
|
|
| 32 |
- router.NewGetRoute("/debug/pprof/trace", frameworkAdaptHandlerFunc(pprof.Trace)),
|
|
| 33 |
- router.NewGetRoute("/debug/pprof/{name}", handlePprof),
|
|
| 34 |
- } |
|
| 35 |
-} |
|
| 36 |
- |
|
| 37 |
-func (r *debugRouter) Routes() []router.Route {
|
|
| 38 |
- return r.routes |
|
| 39 |
-} |
|
| 40 |
- |
|
| 41 |
-func frameworkAdaptHandler(handler http.Handler) httputils.APIFunc {
|
|
| 42 |
- return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
| 43 |
- handler.ServeHTTP(w, r) |
|
| 44 |
- return nil |
|
| 45 |
- } |
|
| 46 |
-} |
|
| 47 |
- |
|
| 48 |
-func frameworkAdaptHandlerFunc(handler http.HandlerFunc) httputils.APIFunc {
|
|
| 49 |
- return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
| 50 |
- handler(w, r) |
|
| 51 |
- return nil |
|
| 52 |
- } |
|
| 53 |
-} |
| 54 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,12 +0,0 @@ |
| 1 |
-package debug |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "context" |
|
| 5 |
- "net/http" |
|
| 6 |
- "net/http/pprof" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-func handlePprof(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
| 10 |
- pprof.Handler(vars["name"]).ServeHTTP(w, r) |
|
| 11 |
- return nil |
|
| 12 |
-} |
| ... | ... |
@@ -23,7 +23,6 @@ import ( |
| 23 | 23 |
buildbackend "github.com/docker/docker/api/server/backend/build" |
| 24 | 24 |
"github.com/docker/docker/api/server/middleware" |
| 25 | 25 |
"github.com/docker/docker/api/server/router" |
| 26 |
- debugrouter "github.com/docker/docker/api/server/router/debug" |
|
| 27 | 26 |
distributionrouter "github.com/docker/docker/api/server/router/distribution" |
| 28 | 27 |
grpcrouter "github.com/docker/docker/api/server/router/grpc" |
| 29 | 28 |
"github.com/docker/docker/api/server/router/image" |
| ... | ... |
@@ -45,6 +44,7 @@ import ( |
| 45 | 45 |
"github.com/docker/docker/daemon/server/router/build" |
| 46 | 46 |
checkpointrouter "github.com/docker/docker/daemon/server/router/checkpoint" |
| 47 | 47 |
"github.com/docker/docker/daemon/server/router/container" |
| 48 |
+ debugrouter "github.com/docker/docker/daemon/server/router/debug" |
|
| 48 | 49 |
"github.com/docker/docker/dockerversion" |
| 49 | 50 |
"github.com/docker/docker/internal/otelutil" |
| 50 | 51 |
"github.com/docker/docker/libcontainerd/supervisor" |
| 51 | 52 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,53 @@ |
| 0 |
+package debug |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "context" |
|
| 4 |
+ "expvar" |
|
| 5 |
+ "net/http" |
|
| 6 |
+ "net/http/pprof" |
|
| 7 |
+ |
|
| 8 |
+ "github.com/docker/docker/api/server/httputils" |
|
| 9 |
+ "github.com/docker/docker/api/server/router" |
|
| 10 |
+) |
|
| 11 |
+ |
|
| 12 |
+// NewRouter creates a new debug router |
|
| 13 |
+// The debug router holds endpoints for debug the daemon, such as those for pprof. |
|
| 14 |
+func NewRouter() router.Router {
|
|
| 15 |
+ r := &debugRouter{}
|
|
| 16 |
+ r.initRoutes() |
|
| 17 |
+ return r |
|
| 18 |
+} |
|
| 19 |
+ |
|
| 20 |
+type debugRouter struct {
|
|
| 21 |
+ routes []router.Route |
|
| 22 |
+} |
|
| 23 |
+ |
|
| 24 |
+func (r *debugRouter) initRoutes() {
|
|
| 25 |
+ r.routes = []router.Route{
|
|
| 26 |
+ router.NewGetRoute("/debug/vars", frameworkAdaptHandler(expvar.Handler())),
|
|
| 27 |
+ router.NewGetRoute("/debug/pprof/", frameworkAdaptHandlerFunc(pprof.Index)),
|
|
| 28 |
+ router.NewGetRoute("/debug/pprof/cmdline", frameworkAdaptHandlerFunc(pprof.Cmdline)),
|
|
| 29 |
+ router.NewGetRoute("/debug/pprof/profile", frameworkAdaptHandlerFunc(pprof.Profile)),
|
|
| 30 |
+ router.NewGetRoute("/debug/pprof/symbol", frameworkAdaptHandlerFunc(pprof.Symbol)),
|
|
| 31 |
+ router.NewGetRoute("/debug/pprof/trace", frameworkAdaptHandlerFunc(pprof.Trace)),
|
|
| 32 |
+ router.NewGetRoute("/debug/pprof/{name}", handlePprof),
|
|
| 33 |
+ } |
|
| 34 |
+} |
|
| 35 |
+ |
|
| 36 |
+func (r *debugRouter) Routes() []router.Route {
|
|
| 37 |
+ return r.routes |
|
| 38 |
+} |
|
| 39 |
+ |
|
| 40 |
+func frameworkAdaptHandler(handler http.Handler) httputils.APIFunc {
|
|
| 41 |
+ return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
| 42 |
+ handler.ServeHTTP(w, r) |
|
| 43 |
+ return nil |
|
| 44 |
+ } |
|
| 45 |
+} |
|
| 46 |
+ |
|
| 47 |
+func frameworkAdaptHandlerFunc(handler http.HandlerFunc) httputils.APIFunc {
|
|
| 48 |
+ return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
| 49 |
+ handler(w, r) |
|
| 50 |
+ return nil |
|
| 51 |
+ } |
|
| 52 |
+} |
| 0 | 53 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,12 @@ |
| 0 |
+package debug |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "context" |
|
| 4 |
+ "net/http" |
|
| 5 |
+ "net/http/pprof" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+func handlePprof(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
| 9 |
+ pprof.Handler(vars["name"]).ServeHTTP(w, r) |
|
| 10 |
+ return nil |
|
| 11 |
+} |