mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Log to default log directory, only if custom configuration failed. (#5393)
This commit is contained in:
parent
603e5fe0bf
commit
1c293781e3
@ -284,19 +284,19 @@ func evalConfigValues() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSpecifedConfigFile(configFile string) {
|
func loadSpecifedConfigFile(configFile string) error {
|
||||||
if configFile == "" {
|
if configFile == "" {
|
||||||
configFile = filepath.Join(HomePath, "conf/custom.ini")
|
configFile = filepath.Join(HomePath, "conf/custom.ini")
|
||||||
// return without error if custom file does not exist
|
// return without error if custom file does not exist
|
||||||
if !pathExists(configFile) {
|
if !pathExists(configFile) {
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
userConfig, err := ini.Load(configFile)
|
userConfig, err := ini.Load(configFile)
|
||||||
userConfig.BlockMode = false
|
userConfig.BlockMode = false
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(3, "Failed to parse %v, %v", configFile, err)
|
return fmt.Errorf("Failed to parse %v, %v", configFile, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, section := range userConfig.Sections() {
|
for _, section := range userConfig.Sections() {
|
||||||
@ -318,6 +318,7 @@ func loadSpecifedConfigFile(configFile string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configFiles = append(configFiles, configFile)
|
configFiles = append(configFiles, configFile)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfiguration(args *CommandLineArgs) {
|
func loadConfiguration(args *CommandLineArgs) {
|
||||||
@ -339,12 +340,12 @@ func loadConfiguration(args *CommandLineArgs) {
|
|||||||
// load default overrides
|
// load default overrides
|
||||||
applyCommandLineDefaultProperties(commandLineProps)
|
applyCommandLineDefaultProperties(commandLineProps)
|
||||||
|
|
||||||
// init logging before specific config so we can log errors from here on
|
|
||||||
DataPath = makeAbsolute(Cfg.Section("paths").Key("data").String(), HomePath)
|
|
||||||
initLogging()
|
|
||||||
|
|
||||||
// load specified config file
|
// load specified config file
|
||||||
loadSpecifedConfigFile(args.Config)
|
err = loadSpecifedConfigFile(args.Config)
|
||||||
|
if err != nil {
|
||||||
|
initLogging()
|
||||||
|
log.Fatal(3, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// apply environment overrides
|
// apply environment overrides
|
||||||
applyEnvVariableOverrides()
|
applyEnvVariableOverrides()
|
||||||
|
Loading…
Reference in New Issue
Block a user