diff --git a/go.mod b/go.mod index 43e61ad..662b9e9 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( fortio.org/cli v1.4.2 - fortio.org/dflag v1.5.3 + fortio.org/dflag v1.6.0 fortio.org/log v1.11.0 fortio.org/version v1.0.3 golang.org/x/sys v0.13.0 @@ -13,5 +13,5 @@ require ( require ( fortio.org/sets v1.0.3 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect ) diff --git a/go.sum b/go.sum index 6df0a5a..b663001 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ fortio.org/assert v1.2.0 h1:XscfvR8yp4xW7OMCvNbCsieRFDxlwdEcb69+JZRp6LA= fortio.org/cli v1.4.2 h1:pCYVPk5FpQuJtD31f9CG8sdgoTOWdv9Gls8As/MLJhU= fortio.org/cli v1.4.2/go.mod h1:VGqFDEKpA6u3NbTM3aSz2lZfAYKnGaszl1pLxbBhxsY= -fortio.org/dflag v1.5.3 h1:+pCqZBCz95PYTxhcmenjrkVORWIRB1Je4eO/So574Bc= -fortio.org/dflag v1.5.3/go.mod h1:cM/ojIzdDv8FRA5yqSRpDK9jCGmASln0k7ag3zeiqbw= +fortio.org/dflag v1.6.0 h1:acOc3KAu1kgp3Ov1nT2GbmcuNhPF1oMZqhT9nj3Oz1U= +fortio.org/dflag v1.6.0/go.mod h1:MeDNYnBh30L6OdMGgAL6ltDX2xdQjOiexCZYPYXH8uM= fortio.org/log v1.11.0 h1:w7ueGPGbXz0A3+ApMz/5Q9gwEMrwSo/ohTlLo2Um6dU= fortio.org/log v1.11.0/go.mod h1:u/8/2lyczXq52aT5Nw6reD+3cR6m/EbS2jBiIYhgiTU= fortio.org/sets v1.0.3 h1:HzewdGjH69YmyW06yzplL35lGr+X4OcqQt0qS6jbaO4= @@ -11,8 +11,8 @@ fortio.org/version v1.0.3 h1:5gJ3plj6isAOMq52cI5ifo4cC+QHmJF76Wevc5Cp4x0= fortio.org/version v1.0.3/go.mod h1:2JQp9Ax+tm6QKiGuzR5nJY63kFeANcgrZ0osoQFDVm0= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= -golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/scli.go b/scli.go index 43662b7..c2244e4 100644 --- a/scli.go +++ b/scli.go @@ -31,6 +31,8 @@ import ( "fortio.org/version" ) +var ConfigMapUpdater *configmap.Updater // Expose the updater if advanced callers want to check warnings or stop it etc. + // NormalizePort parses port and returns host:port if port is in the form // of host:port already or :port if port is only a port (doesn't contain :). // Copied from fortio.org/fnet.NormalizePort to avoid dependency loop. @@ -76,8 +78,12 @@ func ServerMain() bool { cli.ServerMode = true cli.Main() // will call ExitFunction() if there are usage errors if *configDir != "" { - if _, err := configmap.Setup(flag.CommandLine, *configDir); err != nil { + var err error + ConfigMapUpdater, err = configmap.Setup(flag.CommandLine, *configDir) + if err != nil { log.Critf("Unable to watch config/flag changes in %v: %v", *configDir, err) + } else if ConfigMapUpdater.Warnings() != 0 { + log.S(log.Warning, "Unknown flags found", log.Int("count", ConfigMapUpdater.Warnings()), log.Str("dir", *configDir)) } }