move flag blacklisting to main (#1431)
* move flag blacklisting to main Doing it in init() is the wrong place or something else changed. Doing it in main() makes it easy to see *when* this happens. * keep trapsignals
This commit is contained in:
parent
ea95a2003a
commit
aeacbf6e24
1 changed files with 13 additions and 14 deletions
|
@ -18,20 +18,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Reset flag.CommandLine to get rid of unwanted flags for instance from glog (used in kubernetes).
|
|
||||||
// And readd the once we want to keep.
|
|
||||||
flag.VisitAll(func(f *flag.Flag) {
|
|
||||||
if _, ok := flagsBlacklist[f.Name]; ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
flagsToKeep = append(flagsToKeep, f)
|
|
||||||
})
|
|
||||||
|
|
||||||
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
|
|
||||||
for _, f := range flagsToKeep {
|
|
||||||
flag.Var(f.Value, f.Name, f.Usage)
|
|
||||||
}
|
|
||||||
|
|
||||||
caddy.TrapSignals()
|
caddy.TrapSignals()
|
||||||
caddy.DefaultConfigFile = "Corefile"
|
caddy.DefaultConfigFile = "Corefile"
|
||||||
caddy.Quiet = true // don't show init stuff from caddy
|
caddy.Quiet = true // don't show init stuff from caddy
|
||||||
|
@ -54,6 +40,19 @@ func init() {
|
||||||
|
|
||||||
// Run is CoreDNS's main() function.
|
// Run is CoreDNS's main() function.
|
||||||
func Run() {
|
func Run() {
|
||||||
|
// Reset flag.CommandLine to get rid of unwanted flags for instance from glog (used in kubernetes).
|
||||||
|
// And readd the once we want to keep.
|
||||||
|
flag.VisitAll(func(f *flag.Flag) {
|
||||||
|
if _, ok := flagsBlacklist[f.Name]; ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
flagsToKeep = append(flagsToKeep, f)
|
||||||
|
})
|
||||||
|
|
||||||
|
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
|
||||||
|
for _, f := range flagsToKeep {
|
||||||
|
flag.Var(f.Value, f.Name, f.Usage)
|
||||||
|
}
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue