Fix profiler path (#339)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2021-04-25 21:07:23 +02:00
committed by GitHub
parent d7d01b6e40
commit de7eeadcd2
5 changed files with 66 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/signal"
"path"
"runtime"
"strings"
"syscall"
@@ -77,8 +78,12 @@ func main() {
log.Debug().Msg(cfg.String())
// Profiler
if len(cli.Profiler) > 0 {
profilePath := profile.ProfilePath(cfg.Db.Path)
if len(cli.Profiler) > 0 && len(cli.ProfilerPath) > 0 {
profilerPath := path.Clean(cli.ProfilerPath)
if err = os.MkdirAll(profilerPath, os.ModePerm); err != nil {
log.Fatal().Err(err).Msg("Cannot create profiler folder")
}
profilePath := profile.ProfilePath(profilerPath)
switch cli.Profiler {
case "cpu":
defer profile.Start(profile.CPUProfile, profilePath).Stop()