mirror of
https://github.com/minio/minio.git
synced 2025-11-07 04:42:56 -05:00
server: Enable server profiling as needed. (#1565)
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
f733120d3d
commit
b66c3bf35e
18
main.go
18
main.go
@@ -19,6 +19,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -28,6 +29,7 @@ import (
|
||||
"github.com/minio/mc/pkg/console"
|
||||
"github.com/minio/minio/pkg/probe"
|
||||
"github.com/olekukonko/ts"
|
||||
"github.com/pkg/profile"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -176,7 +178,23 @@ func checkMainSyntax(c *cli.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// mustGetProfilePath must get location that the profile will be written to.
|
||||
func mustGetProfilePath() string {
|
||||
return filepath.Join(mustGetConfigPath(), globalMinioProfilePath)
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Enable profiling supported modes are [cpu, mem, block].
|
||||
// ``MINIO_PROFILER`` supported options are [cpu, mem, block].
|
||||
switch os.Getenv("MINIO_PROFILER") {
|
||||
case "cpu":
|
||||
defer profile.Start(profile.CPUProfile, profile.ProfilePath(mustGetProfilePath())).Stop()
|
||||
case "mem":
|
||||
defer profile.Start(profile.MemProfile, profile.ProfilePath(mustGetProfilePath())).Stop()
|
||||
case "block":
|
||||
defer profile.Start(profile.BlockProfile, profile.ProfilePath(mustGetProfilePath())).Stop()
|
||||
}
|
||||
|
||||
probe.Init() // Set project's root source path.
|
||||
probe.SetAppInfo("Release-Tag", minioReleaseTag)
|
||||
probe.SetAppInfo("Commit-ID", minioShortCommitID)
|
||||
|
||||
Reference in New Issue
Block a user