Daemon remembers the config path if started with --config flag
This commit is contained in:
@@ -31,7 +31,7 @@ Alongside this project, I am developing a seperate web-based dashboard that can
|
||||
|
||||
- [ ] Configuration
|
||||
- [x] Custom configuration path (passed to the daemon with a flag `--config`)
|
||||
- [ ] Daemon instance remembers config path (*so you don't have to pass `--config` everytime you run an ipc command*)
|
||||
- [x] Daemon instance remembers config path (*so you don't have to pass `--config` everytime you run an ipc command*)
|
||||
- [ ] Daemon listen port (kind of implemented, could be cleaner)
|
||||
- [x] Declarative Server configuration (Create servers in config)
|
||||
- [ ] More configuration options
|
||||
|
||||
19
main.go
19
main.go
@@ -34,11 +34,30 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
configExplicitlySet := false
|
||||
flag.Visit(func(f *flag.Flag) {
|
||||
if f.Name == "config" {
|
||||
configExplicitlySet = true
|
||||
}
|
||||
})
|
||||
|
||||
if !configExplicitlySet {
|
||||
if envConfig := os.Getenv("VSSM_CONFIG_PATH"); envConfig != "" {
|
||||
configFlag = &envConfig
|
||||
}
|
||||
}
|
||||
|
||||
absConfigPath, err := filepath.Abs(*configFlag)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to resolve absolute configuration path target: %v", err)
|
||||
}
|
||||
|
||||
if configExplicitlySet {
|
||||
if err := os.Setenv("VSSM_CONFIG_PATH", absConfigPath); err != nil {
|
||||
log.Fatalf("Warning: could not set VSSM_CONFIG_PATH: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
cfg, err := LoadOrCreateConfig(absConfigPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Initialization failed: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user