1
0
mirror of https://github.com/openshift/image-registry.git synced 2026-02-05 09:45:55 +01:00

Add code from the origin repository

This commit is contained in:
Oleg Bulatov
2017-11-07 15:10:48 +01:00
parent 856bf845d0
commit a5b4ea8369
9 changed files with 413 additions and 30 deletions

View File

@@ -14,7 +14,6 @@ import (
"k8s.io/kubernetes/pkg/util/logs"
"github.com/openshift/image-registry/pkg/cmd/dockerregistry"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/cmd/util/serviceability"
)
@@ -53,12 +52,20 @@ func main() {
dockerregistry.Execute(configFile)
}
func env(key string, defaultValue string) string {
val := os.Getenv(key)
if len(val) == 0 {
return defaultValue
}
return val
}
func startProfiler() {
if cmdutil.Env("OPENSHIFT_PROFILE", "") == "web" {
if env("OPENSHIFT_PROFILE", "") == "web" {
go func() {
runtime.SetBlockProfileRate(1)
profilePort := cmdutil.Env("OPENSHIFT_PROFILE_PORT", "6060")
profileHost := cmdutil.Env("OPENSHIFT_PROFILE_HOST", "127.0.0.1")
profilePort := env("OPENSHIFT_PROFILE_PORT", "6060")
profileHost := env("OPENSHIFT_PROFILE_HOST", "127.0.0.1")
log.Infof(fmt.Sprintf("Starting profiling endpoint at http://%s:%s/debug/pprof/", profileHost, profilePort))
log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%s", profileHost, profilePort), nil))
}()