File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 3333 cfg config.Config
3434 appContext * utils.AppContext
3535 scheduler * gocron.Scheduler
36- configChangeCallback func ()
3736
3837 rootCmd = & cobra.Command {
3938 Use : "k8s-shredder" ,
@@ -122,12 +121,10 @@ func discoverConfig() {
122121 viper .WatchConfig ()
123122 viper .OnConfigChange (func (e fsnotify.Event ) {
124123 log .Infof ("Configuration file `%s` changed, attempting to reload" , e .Name )
125- if configChangeCallback != nil {
126- reset ()
127- parseConfig ()
128- configChangeCallback ()
129- run (& cobra.Command {}, []string {})
130- }
124+ reset ()
125+ parseConfig ()
126+ appContext .Config = cfg
127+ run (& cobra.Command {}, []string {})
131128 })
132129}
133130
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ package metrics
1414import (
1515 "fmt"
1616 "net/http"
17+ "time"
1718
1819 log "github.com/sirupsen/logrus"
1920
@@ -63,8 +64,13 @@ func serve(port int) error {
6364 }
6465 })
6566
67+ server := & http.Server {
68+ Addr : fmt .Sprintf (":%d" , port ),
69+ ReadHeaderTimeout : 3 * time .Second ,
70+ }
71+
6672 go func () {
67- log .Fatal (http .ListenAndServe (fmt . Sprintf ( ":%d" , port ), nil ) )
73+ log .Fatal (server .ListenAndServe (), nil )
6874 }()
6975 return nil
7076}
You can’t perform that action at this time.
0 commit comments