feat(instrumentation): work on settings model for internal metrics publishing, #4696

This commit is contained in:
Torkel Ödegaard
2016-06-02 14:32:17 +02:00
parent 74101eaf7c
commit 6b2a4fe8e8
10 changed files with 163 additions and 70 deletions
+27 -3
View File
@@ -37,9 +37,10 @@ const (
var (
// App settings.
Env string = DEV
AppUrl string
AppSubUrl string
Env string = DEV
AppUrl string
AppSubUrl string
InstanceName string
// build
BuildVersion string
@@ -259,6 +260,12 @@ func evalEnvVarExpression(value string) string {
envVar = strings.TrimPrefix(envVar, "${")
envVar = strings.TrimSuffix(envVar, "}")
envValue := os.Getenv(envVar)
// if env variable is hostname and it is emtpy use os.Hostname as default
if envVar == "HOSTNAME" && envValue == "" {
envValue, _ = os.Hostname()
}
return envValue
})
}
@@ -395,11 +402,28 @@ func validateStaticRootPath() error {
return fmt.Errorf("Failed to detect generated css or javascript files in static root (%s), have you executed default grunt task?", StaticRootPath)
}
// func readInstanceName() string {
// hostname, _ := os.Hostname()
// if hostname == "" {
// hostname = "hostname_unknown"
// }
//
// instanceName := Cfg.Section("").Key("instance_name").MustString("")
// if instanceName = "" {
// // set value as it might be used in other places
// Cfg.Section("").Key("instance_name").SetValue(hostname)
// instanceName = hostname
// }
//
// return
// }
func NewConfigContext(args *CommandLineArgs) error {
setHomePath(args)
loadConfiguration(args)
Env = Cfg.Section("").Key("app_mode").MustString("development")
InstanceName = Cfg.Section("").Key("instance_name").MustString("unknown_instance_name")
PluginsPath = Cfg.Section("paths").Key("plugins").String()
server := Cfg.Section("server")