at v0.4.1
1 | // See LICENSE file for copyright and license details |
2 | |
3 | package serve |
4 | |
5 | import ( |
6 | "fmt" |
7 | "os" |
8 | "os/signal" |
9 | "syscall" |
10 | |
11 | "djmo.ch/go-shrt" |
12 | ) |
13 | |
14 | func init() { |
15 | hangup = func(h *shrt.ShrtHandler) { |
16 | hup := make(chan os.Signal, 1) |
17 | signal.Notify(hup, syscall.SIGHUP) |
18 | for { |
19 | <-hup |
20 | f, err := h.FS.Open(h.Config.DbPath) |
21 | if err != nil { |
22 | panic(fmt.Sprint("could not open", h.Config.DbPath)) |
23 | } |
24 | err = h.ShrtFile.ReadShrtFile(f) |
25 | if err != nil { |
26 | panic(fmt.Sprint("db error:", err)) |
27 | } |
28 | } |
29 | } |
30 | } |