|
|
@ -63,6 +63,9 @@ func init() { |
|
|
|
// Check if minio was compiled using a supported version of Golang.
|
|
|
|
// Check if minio was compiled using a supported version of Golang.
|
|
|
|
checkGoVersion() |
|
|
|
checkGoVersion() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set global trace flag.
|
|
|
|
|
|
|
|
globalTrace = os.Getenv("MINIO_TRACE") == "1" |
|
|
|
|
|
|
|
|
|
|
|
// It is an unsafe practice to run network services as
|
|
|
|
// It is an unsafe practice to run network services as
|
|
|
|
// root. Containers are an exception.
|
|
|
|
// root. Containers are an exception.
|
|
|
|
if !isContainerized() && os.Geteuid() == 0 { |
|
|
|
if !isContainerized() && os.Geteuid() == 0 { |
|
|
@ -150,31 +153,11 @@ func mustGetProfilePath() string { |
|
|
|
return filepath.Join(mustGetConfigPath(), globalMinioProfilePath) |
|
|
|
return filepath.Join(mustGetConfigPath(), globalMinioProfilePath) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func setupProfilingFromEnv(profiler *interface { |
|
|
|
|
|
|
|
Stop() |
|
|
|
|
|
|
|
}) { |
|
|
|
|
|
|
|
switch os.Getenv("MINIO_PROFILER") { |
|
|
|
|
|
|
|
case "cpu": |
|
|
|
|
|
|
|
*profiler = profile.Start(profile.CPUProfile, profile.ProfilePath(mustGetProfilePath())) |
|
|
|
|
|
|
|
case "mem": |
|
|
|
|
|
|
|
*profiler = profile.Start(profile.MemProfile, profile.ProfilePath(mustGetProfilePath())) |
|
|
|
|
|
|
|
case "block": |
|
|
|
|
|
|
|
*profiler = profile.Start(profile.BlockProfile, profile.ProfilePath(mustGetProfilePath())) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
// Set global trace flag.
|
|
|
|
|
|
|
|
trace := os.Getenv("MINIO_TRACE") |
|
|
|
|
|
|
|
globalTrace = trace == "1" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
probe.Init() // Set project's root source path.
|
|
|
|
probe.Init() // Set project's root source path.
|
|
|
|
probe.SetAppInfo("Release-Tag", minioReleaseTag) |
|
|
|
probe.SetAppInfo("Release-Tag", minioReleaseTag) |
|
|
|
probe.SetAppInfo("Commit-ID", minioShortCommitID) |
|
|
|
probe.SetAppInfo("Commit-ID", minioShortCommitID) |
|
|
|
|
|
|
|
|
|
|
|
var profiler interface { |
|
|
|
|
|
|
|
Stop() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
app := registerApp() |
|
|
|
app := registerApp() |
|
|
|
app.Before = func(c *cli.Context) error { |
|
|
|
app.Before = func(c *cli.Context) error { |
|
|
|
// Sets new config folder.
|
|
|
|
// Sets new config folder.
|
|
|
@ -209,21 +192,18 @@ func main() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Enable profiling supported modes are [cpu, mem, block].
|
|
|
|
|
|
|
|
// ``MINIO_PROFILER`` supported options are [cpu, mem, block].
|
|
|
|
|
|
|
|
setupProfilingFromEnv(&profiler) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Return here.
|
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Stop profiling on exit.
|
|
|
|
// Enable profiler if ``MINIO_PROFILER`` is set. Supported options are [cpu, mem, block].
|
|
|
|
// N B If any inner function calls os.Exit() the defer(s) stacked wouldn't be called
|
|
|
|
switch os.Getenv("MINIO_PROFILER") { |
|
|
|
defer func() { |
|
|
|
case "cpu": |
|
|
|
if profiler != nil { |
|
|
|
defer profile.Start(profile.CPUProfile, profile.ProfilePath(mustGetProfilePath())).Stop() |
|
|
|
profiler.Stop() |
|
|
|
case "mem": |
|
|
|
} |
|
|
|
defer profile.Start(profile.MemProfile, profile.ProfilePath(mustGetProfilePath())).Stop() |
|
|
|
}() |
|
|
|
case "block": |
|
|
|
|
|
|
|
defer profile.Start(profile.BlockProfile, profile.ProfilePath(mustGetProfilePath())).Stop() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Run the app - exit on error.
|
|
|
|
// Run the app - exit on error.
|
|
|
|
app.RunAndExitOnError() |
|
|
|
app.RunAndExitOnError() |
|
|
|