Compare commits
2 Commits
e8ec5009c8
...
c8822b9e33
Author | SHA1 | Date |
---|---|---|
gapodo | c8822b9e33 | |
gapodo | 4124e626f4 |
2
Makefile
2
Makefile
|
@ -182,7 +182,7 @@ release-sources: | $(DIST_DIRS)
|
|||
rm -f $(STORED_VERSION_FILE)
|
||||
|
||||
.PHONY: release ## Prepare a full release
|
||||
release: build-linux release-copy release-compress vendor release-sources release-check
|
||||
release: build-linux # release-copy release-compress vendor release-sources release-check
|
||||
|
||||
.PHONY: dockerize
|
||||
dockerize: | $(DIST_DIRS)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue