diff --git a/pkg/configuration/configuration.go b/pkg/configuration/configuration.go index e0aa68e..559911e 100644 --- a/pkg/configuration/configuration.go +++ b/pkg/configuration/configuration.go @@ -5,6 +5,7 @@ package configuration import ( "fmt" + "log" "os" "git.kle.li/tools/go-import-redirector/pkg/configuration/file" @@ -24,8 +25,6 @@ func New(cfgFile string, hotReload bool, reloadFunction func()) *Configuration { v: viper.New(), } - c.v.Debug() - if cfgFile != "" { // Use Configurationfile from the flag. c.v.SetConfigFile(cfgFile) @@ -67,6 +66,7 @@ func New(cfgFile string, hotReload bool, reloadFunction func()) *Configuration { } func (c *Configuration) updateConfig(_ fsnotify.Event) { + log.Println("Hot reload triggered") c.loadCfgFile() if c.r != nil { diff --git a/pkg/packagelist/packagelist.go b/pkg/packagelist/packagelist.go index 03eedb2..cf92666 100644 --- a/pkg/packagelist/packagelist.go +++ b/pkg/packagelist/packagelist.go @@ -5,6 +5,7 @@ package packagelist import ( "fmt" + "log" "net/http" "strings" @@ -134,6 +135,7 @@ func (pl *PackageList) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + log.Println("Path is " + r.URL.Path) if r.URL.Path == "/" { if pkg, ok := pl.GetMostSpecificPackage(""); ok { err := indexTmpl.Execute(w, map[string]interface{}{ @@ -155,7 +157,6 @@ func (pl *PackageList) ServeHTTP(w http.ResponseWriter, r *http.Request) { } return } - fmt.Println("Path is " + r.URL.Path) if pkg, ok := pl.GetMostSpecificPackage(r.URL.Path); ok { err := pkgTmpl.Execute(w, map[string]interface{}{ "pkg": pkg, diff --git a/pkg/server/server.go b/pkg/server/server.go index fc9ae5f..73fe9d4 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -44,17 +44,21 @@ func (s *Server) startHTTPServer() { } func (s *Server) Restart(pkgs *packagelist.PackageList) { + log.Println("started reloading config") s.Shutdown() s.Start(pkgs) + log.Println("server restarted") } func (s *Server) Start(pkgs *packagelist.PackageList) { + log.Println("Starting server") s.pkgs = pkgs s.wg.Add(1) s.startHTTPServer() } func (s *Server) Shutdown() { + log.Println("Stopping server") ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() if err := s.srv.Shutdown(ctx); err != nil {