diff options
Diffstat (limited to 'cmd/koushin')
-rw-r--r-- | cmd/koushin/main.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/cmd/koushin/main.go b/cmd/koushin/main.go index 0f6c776..a0382dd 100644 --- a/cmd/koushin/main.go +++ b/cmd/koushin/main.go @@ -3,6 +3,9 @@ package main import ( "flag" "fmt" + "os" + "os/signal" + "syscall" "git.sr.ht/~emersion/koushin" "github.com/labstack/echo/v4" @@ -35,10 +38,22 @@ func main() { if l, ok := e.Logger.(*log.Logger); ok { l.SetHeader("${time_rfc3339} ${level}") } - _, err := koushin.New(e, &options) + s, err := koushin.New(e, &options) if err != nil { e.Logger.Fatal(err) } e.Use(middleware.Recover()) + + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGUSR1) + go func() { + for range sigs { + e.Logger.Printf("Reloading server") + if err := s.Reload(); err != nil { + e.Logger.Errorf("Failed to reload server: %v", err) + } + } + }() + e.Logger.Fatal(e.Start(":1323")) } |