Add pprof port controlled by env
@@ -18,10 +18,13 @@ package main
import (
"flag"
+ "fmt"
"io"
"net/http"
+ _ "net/http/pprof"
"os"
"path"
+ "strconv"
"strings"
"sync"
"time"
@@ -144,6 +147,18 @@ func main() {
default:
}
+ // enable pprof analyse
+ pprofPort := os.Getenv("PPROF_PORT")
+ if pprofPort != "" {
+ if _, err := strconv.Atoi(pprofPort); err == nil {
+ log.Infof("enable pprof & start port at %v", pprofPort)
+ go func() {
+ err := http.ListenAndServe(fmt.Sprintf("0.0.0.0:%v", pprofPort), nil)
+ log.Errorf("start server err: %v", err)
+ }()
+ }
+ }
+
setLogAttribute(logAttribute)
log.Infof("Multi CSI Driver Name: %s, nodeID: %s, endPoints: %s", *driver, *nodeID, *endpoint)
@@ -282,6 +297,7 @@ func main() {
if err := server.ListenAndServe(); err != nil {
log.Fatalf("Service port listen and serve err:%s", err.Error())
}
+
wg.Wait()
os.Exit(0)
}
