mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 14:34:24 +08:00
Serve expvars and pprof on the API port
This commit is contained in:
@ -1,7 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "expvar"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -76,6 +79,17 @@ the port as you would other services or database (firewall, authenticated proxy,
|
|||||||
Run: daemonFunc,
|
Run: daemonFunc,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// defaultMux tells mux to serve path using the default muxer. This is
|
||||||
|
// mostly useful to hook up things that register in the default muxer,
|
||||||
|
// and don't provide a convenient http.Handler entry point, such as
|
||||||
|
// expvar and http/pprof.
|
||||||
|
func defaultMux(path string) func(node *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
|
||||||
|
return func(node *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
|
||||||
|
mux.Handle(path, http.DefaultServeMux)
|
||||||
|
return mux, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func daemonFunc(req cmds.Request, res cmds.Response) {
|
func daemonFunc(req cmds.Request, res cmds.Response) {
|
||||||
// let the user know we're going.
|
// let the user know we're going.
|
||||||
fmt.Printf("Initializing daemon...\n")
|
fmt.Printf("Initializing daemon...\n")
|
||||||
@ -281,6 +295,8 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
|
|||||||
corehttp.WebUIOption,
|
corehttp.WebUIOption,
|
||||||
gateway.ServeOption(),
|
gateway.ServeOption(),
|
||||||
corehttp.VersionOption(),
|
corehttp.VersionOption(),
|
||||||
|
defaultMux("/debug/vars"),
|
||||||
|
defaultMux("/debug/pprof/"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if rootRedirect != nil {
|
if rootRedirect != nil {
|
||||||
|
Reference in New Issue
Block a user