]> Cypherpunks.ru repositories - gocheese.git/blobdiff - gocheese.go
Refresh -passwd file while working
[gocheese.git] / gocheese.go
index 6ca3ad53e036236ea7dc3310e74d55641f715bbb..fa3b4302f3770b1836be22a26d423ff6144a5d53 100644 (file)
@@ -31,10 +31,12 @@ import (
        "net/http"
        "net/url"
        "os"
+       "os/signal"
        "path/filepath"
        "regexp"
        "runtime"
        "strings"
+       "syscall"
 )
 
 const (
@@ -462,6 +464,13 @@ func main() {
        }
        refreshPasswd()
        log.Println("root:", *root, "bind:", *bind)
+       needsRefreshPasswd := make(chan os.Signal, 0)
+       signal.Notify(needsRefreshPasswd, syscall.SIGHUP)
+       go func() {
+               for range needsRefreshPasswd {
+                       refreshPasswd()
+               }
+       }()
        http.HandleFunc(*norefreshURLPath, handler)
        http.HandleFunc(*refreshURLPath, handler)
        log.Fatal(http.ListenAndServe(*bind, nil))