added manger to keep track of go routines in the services (#2869)

- added manager to wait for all go routines to end before exit
- code refactor
- renamed Manafer to Interface and GoRoutineManager to GroupManager
- replaced some go routine calls with manager Add func
- added unit tests for manager
This commit is contained in:
Vardhaman Surana
2023-11-07 15:30:48 +05:30
committed by GitHub
parent 27132975c4
commit 2a40b4538c
24 changed files with 283 additions and 67 deletions
+5 -2
View File
@@ -32,9 +32,10 @@ import (
"go.uber.org/zap"
"github.com/fission/fission/pkg/utils/httpserver"
"github.com/fission/fission/pkg/utils/manager"
)
func ProfileIfEnabled(ctx context.Context, logger *zap.Logger) {
func ProfileIfEnabled(ctx context.Context, logger *zap.Logger, mgr manager.Interface) {
enablePprof := os.Getenv("PPROF_ENABLED")
if enablePprof != "true" {
return
@@ -47,5 +48,7 @@ func ProfileIfEnabled(ctx context.Context, logger *zap.Logger) {
pprofMux := http.DefaultServeMux
http.DefaultServeMux = http.NewServeMux()
go httpserver.StartServer(ctx, logger, "pprof", pprofPort, pprofMux)
mgr.Add(ctx, func(ctx context.Context) {
httpserver.StartServer(ctx, logger, mgr, "pprof", pprofPort, pprofMux)
})
}