Skip to content

Commit

Permalink
register pprof endpoint w web app port 9711
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Nov 10, 2024
1 parent b3e60d4 commit 1fa587a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion engine/server/engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const (
functionPathSeparator = "."
emptyFunctionName = ""
webappPortAddr = ":9711"
pprofPath = "/debug/pprof/"

remoteBackendConfigFilename = "remote_backend_config.json"
pathToStaticFolder = "/run/webapp"
Expand Down Expand Up @@ -213,8 +214,9 @@ func runMain() error {
}
logrus.Debugf("Created environment js file with content: \n%s", envJsFileContent)

handler := http.NewServeMux()
fileServer := http.FileServer(http.Dir(pathToStaticFolder))
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
path, err := filepath.Abs(r.URL.Path)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
Expand All @@ -236,6 +238,7 @@ func runMain() error {
w.Header().Add("Cache-Control", "no-store")
fileServer.ServeHTTP(w, r)
})
handler.Handle(pprofPath, http.HandlerFunc(http.DefaultServeMux.ServeHTTP))

err := http.ListenAndServe(webappPortAddr, handler)
if err != nil {
Expand Down

0 comments on commit 1fa587a

Please sign in to comment.