Skip to content

Commit e6d6637

Browse files
committed
fix: server bring flag load before loading in config file
1 parent 78c1979 commit e6d6637

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

cmd/server/main.go

+11-12
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@ func main() {
2828
serverHost := flag.String("h", "localhost", "Server host for SSE transport")
2929
flag.Parse()
3030

31-
// Load configuration after environment variables are set
32-
cfg, err := config.LoadConfig()
33-
if err != nil {
34-
log.Printf("Warning: Failed to load configuration: %v", err)
35-
// Create a default config if loading fails
36-
cfg = &config.Config{
37-
ServerPort: *serverPort,
38-
TransportMode: *transportMode,
39-
ConfigPath: *configFile,
40-
}
41-
}
4231
// Set environment variables from command line arguments if provided
4332
if *configFile != "config.json" {
4433
os.Setenv("CONFIG_PATH", *configFile)
@@ -50,7 +39,17 @@ func main() {
5039
os.Setenv("SERVER_PORT", fmt.Sprintf("%d", *serverPort))
5140
}
5241

53-
// Initialize database connection from config
42+
// Load configuration after environment variables are set
43+
cfg, err := config.LoadConfig()
44+
if err != nil {
45+
log.Printf("Warning: Failed to load configuration: %v", err)
46+
// Create a default config if loading fails
47+
cfg = &config.Config{
48+
ServerPort: *serverPort,
49+
TransportMode: *transportMode,
50+
ConfigPath: *configFile,
51+
}
52+
} // Initialize database connection from config
5453
dbConfig := &dbtools.Config{
5554
ConfigFile: cfg.ConfigPath,
5655
}

0 commit comments

Comments
 (0)