]> Cypherpunks.ru repositories - gocheese.git/commitdiff
Refresh -passwd file while working
authorElena Balakhonova <balakhonova@rnd.stcnet.ru>
Tue, 3 Dec 2019 13:12:12 +0000 (16:12 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 3 Dec 2019 13:38:59 +0000 (16:38 +0300)
README
gocheese.go

diff --git a/README b/README
index 555b19b3bb800e76c7549aaf02504fb646931a15..d128489e32f67c6d1b1500c4ff01cad950df5b47 100644 (file)
--- a/README
+++ b/README
@@ -63,6 +63,13 @@ hashed passwords:
     foo:$sha256$fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9
     foo:$argon2i$v=19$m=32768,t=3,p=4$OGU5MTM3YjVlYzQwZjhkZA$rVn53v6Ckpf7WH0676ZQLr9Hbm6VH3YnL6I9ONJcIIU
 
+While daemon working you can refresh -passwd file with SIGHUP:
+
+    $ kill -HUP `pidof gocheese`
+
+Before refreshing it's recommended to check -passwd file with -passwd-check
+option to prevent daemon failure
+
                          On-disk storage format
                          ======================
 
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))