From e0ead6773728876f1348d70b205f5aab0a5742aa Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 26 Jun 2014 17:19:18 -0400 Subject: [PATCH] defer pprof.StopCPUProfile() --- main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index a7fab7c..19d5ddc 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,11 @@ func main() { pprof.StartCPUProfile(f) log.V(1).Info("started profiling") + + defer func() { + pprof.StopCPUProfile() + log.V(1).Info("stopped profiling") + }() } // Load the config file. @@ -65,11 +70,6 @@ func main() { <-interrupts log.V(1).Info("caught interrupt, shutting down...") - if profile { - pprof.StopCPUProfile() - log.V(1).Info("stopped profiling") - } - err := s.Stop() if err != nil { log.Fatalf("failed to shutdown cleanly: %s", err)