profiler: Fix how we generate profiles. (#2596)

Fixes #2594
This commit is contained in:
Harshavardhana
2016-09-01 03:50:31 -07:00
committed by GitHub
parent 790ad68d4d
commit 511a8cbe04
3 changed files with 34 additions and 3 deletions

View File

@@ -201,8 +201,18 @@ func startMonitorShutdownSignal(onExitFn onExitFunc) error {
if err != nil {
errorIf(errors.New("Unable to reboot."), err.Error())
}
// Successfully forked.
onExitFn(int(exitSuccess))
}
// Enable profiler if ``MINIO_PROFILER`` is set.
switch os.Getenv("MINIO_PROFILER") {
case "cpu", "mem", "block":
// Stop any running profiler.
globalProfiler.Stop()
}
// Exit as success if no errors.
onExitFn(int(exitSuccess))
}
}