mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
cmd/ctrld: only write to config file if listener config changed
Updates #149
This commit is contained in:
committed by
Cuong Manh Le
parent
7ce62ccaec
commit
f39512b4c0
+11
-7
@@ -208,16 +208,18 @@ func initCLI() {
|
|||||||
processCDFlags()
|
processCDFlags()
|
||||||
}
|
}
|
||||||
|
|
||||||
updateListenerConfig()
|
updated := updateListenerConfig()
|
||||||
|
|
||||||
if cdUID != "" {
|
if cdUID != "" {
|
||||||
processLogAndCacheFlags()
|
processLogAndCacheFlags()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := writeConfigFile(); err != nil {
|
if updated {
|
||||||
mainLog.Load().Fatal().Err(err).Msg("failed to write config file")
|
if err := writeConfigFile(); err != nil {
|
||||||
} else {
|
mainLog.Load().Fatal().Err(err).Msg("failed to write config file")
|
||||||
mainLog.Load().Info().Msg("writing config file to: " + defaultConfigFile)
|
} else {
|
||||||
|
mainLog.Load().Info().Msg("writing config file to: " + defaultConfigFile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if newLogPath := cfg.Service.LogPath; newLogPath != "" && oldLogPath != newLogPath {
|
if newLogPath := cfg.Service.LogPath; newLogPath != "" && oldLogPath != newLogPath {
|
||||||
@@ -1412,8 +1414,8 @@ type listenerConfigCheck struct {
|
|||||||
|
|
||||||
// updateListenerConfig updates the config for listeners if not defined,
|
// updateListenerConfig updates the config for listeners if not defined,
|
||||||
// or defined but invalid to be used, e.g: using loopback address other
|
// or defined but invalid to be used, e.g: using loopback address other
|
||||||
// than 127.0.0.1 with sytemd-resolved.
|
// than 127.0.0.1 with systemd-resolved.
|
||||||
func updateListenerConfig() {
|
func updateListenerConfig() (updated bool) {
|
||||||
lcc := make(map[string]*listenerConfigCheck)
|
lcc := make(map[string]*listenerConfigCheck)
|
||||||
cdMode := cdUID != ""
|
cdMode := cdUID != ""
|
||||||
for n, listener := range cfg.Listener {
|
for n, listener := range cfg.Listener {
|
||||||
@@ -1431,6 +1433,7 @@ func updateListenerConfig() {
|
|||||||
lcc[n].IP = true
|
lcc[n].IP = true
|
||||||
lcc[n].Port = true
|
lcc[n].Port = true
|
||||||
}
|
}
|
||||||
|
updated = updated || lcc[n].IP || lcc[n].Port
|
||||||
}
|
}
|
||||||
|
|
||||||
var closers []io.Closer
|
var closers []io.Closer
|
||||||
@@ -1603,6 +1606,7 @@ func updateListenerConfig() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func dirWritable(dir string) (bool, error) {
|
func dirWritable(dir string) (bool, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user