Skip to content

Commit

Permalink
[FAB-11241] Move Profiling init Service external
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Baohua Yang <[email protected]>
  • Loading branch information
yeasy authored and mastersingh24 committed Nov 26, 2019
1 parent db3b1cc commit 24afa12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions orderer/common/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion orderer/common/server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 24afa12

Please sign in to comment.