Skip to content

Commit

Permalink
fix: improve default config file name (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
microup authored Aug 6, 2023
1 parent c062d44 commit 5239c10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/app/vbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (

// Run this is the function of an application that starts a proxy server.
func Run() {
runtime.GOMAXPROCS(runtime.NumCPU())

defer func() {
if err := recover(); err != nil {
fmt.Printf("catch err: %v", err) //nolint:forbidigo
Expand Down Expand Up @@ -62,16 +64,14 @@ func Run() {

// initializeConfig is the function that initializes the configuration of the application.
func initializeConfig() *config.Config {
runtime.GOMAXPROCS(runtime.NumCPU())

configFile := os.Getenv("ConfigFile")

if configFile == "." {
configFile = "../../config"
}

cfg := config.New()

if configFile == "" {
configFile = config.DefaultConfigFile
}

if err := cfg.Load(configFile); err != nil {
log.Fatalf("%v", err)
}
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

// DefaultProxyPort is the default port for the proxy server.
const DefaultProxyPort = 8080
const DefaultConfigFile = "config.yaml"

// Config is the configuration of the proxy server.
type Config struct {
Expand Down

0 comments on commit 5239c10

Please sign in to comment.