Skip to content

Commit

Permalink
Merge pull request #41 from qonto/fix-memory-usage-boot
Browse files Browse the repository at this point in the history
Avoid memory spike during boot
  • Loading branch information
vmercierfr authored Nov 27, 2023
2 parents 0650ed2 + 402b1e2 commit 0e1a172
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package cmd
import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
Expand Down Expand Up @@ -207,15 +208,23 @@ func initConfig() {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
// Find home directory
home, err := os.UserHomeDir()
cobra.CheckErr(err)

// Search config in home directory or current directory with name ".rds-exporter" (without extension).
viper.AddConfigPath(".")
viper.AddConfigPath(home)
viper.SetConfigType("yaml")
viper.SetConfigName("prometheus-rds-exporter")
// Search config in home directory or current directory with name "prometheus-rds-exporter.yaml"

configurationFilename := "prometheus-rds-exporter.yaml"
currentPathFilename := configurationFilename
homeFilename := filepath.Join(home, configurationFilename)

if _, err := os.Stat(homeFilename); err == nil {
viper.SetConfigFile(homeFilename)
}

if _, err := os.Stat(currentPathFilename); err == nil {
viper.SetConfigFile(currentPathFilename)
}
}

if err := viper.ReadInConfig(); err == nil {
Expand Down

0 comments on commit 0e1a172

Please sign in to comment.