From 24afa1298889308ba98074495d6e722f248226d0 Mon Sep 17 00:00:00 2001 From: Baohua Yang Date: Fri, 20 Jul 2018 09:16:10 +0800 Subject: [PATCH] [FAB-11241] Move Profiling init Service external Now the flag is inside the function, moving it into the main process will make the entire logic more explicit. Change-Id: Ic53aa5b44755cb352ea7693f039355f9fceddcd7 Signed-off-by: Baohua Yang Signed-off-by: Baohua Yang --- orderer/common/server/main.go | 14 ++++++-------- orderer/common/server/main_test.go | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/orderer/common/server/main.go b/orderer/common/server/main.go index 1749fa2939b..9565366e755 100644 --- a/orderer/common/server/main.go +++ b/orderer/common/server/main.go @@ -236,7 +236,9 @@ func Main() { go clusterGRPCServer.Start() } - initializeProfilingService(conf) + if conf.General.Profile.Enabled { + go initializeProfilingService(conf) + } ab.RegisterAtomicBroadcastServer(grpcServer.Server(), server) logger.Info("Beginning to serve requests") grpcServer.Start() @@ -372,13 +374,9 @@ func initializeLogging() { // Start the profiling service if enabled. func initializeProfilingService(conf *localconfig.TopLevel) { - if conf.General.Profile.Enabled { - go func() { - logger.Info("Starting Go pprof profiling service on:", conf.General.Profile.Address) - // The ListenAndServe() call does not return unless an error occurs. - logger.Panic("Go pprof service failed:", http.ListenAndServe(conf.General.Profile.Address, nil)) - }() - } + logger.Info("Starting Go pprof profiling service on:", conf.General.Profile.Address) + // The ListenAndServe() call does not return unless an error occurs. + logger.Panic("Go pprof service failed:", http.ListenAndServe(conf.General.Profile.Address, nil)) } func handleSignals(handlers map[os.Signal]func()) { diff --git a/orderer/common/server/main_test.go b/orderer/common/server/main_test.go index 9b6876189c1..4e3c5730075 100644 --- a/orderer/common/server/main_test.go +++ b/orderer/common/server/main_test.go @@ -73,7 +73,7 @@ func TestInitializeProfilingService(t *testing.T) { l.Close() return l.Addr().String() }() - initializeProfilingService( + go initializeProfilingService( &localconfig.TopLevel{ General: localconfig.General{ Profile: localconfig.Profile{