[mirror] Scalable static site server for Git forges (like GitHub Pages)
1// See https://pkg.go.dev/os/signal#hdr-Windows for a description of what this module
2// will do on Windows (tl;dr nothing calls the reload handler, the interrupt handler works
3// more or less how you'd expect).
4
5package git_pages
6
7import (
8 "os"
9 "os/signal"
10 "syscall"
11)
12
13func OnReload(handler func()) {
14 sighup := make(chan os.Signal, 1)
15 signal.Notify(sighup, syscall.SIGHUP)
16 go func() {
17 for {
18 <-sighup
19 handler()
20 }
21 }()
22}
23
24func WaitForInterrupt() {
25 sigint := make(chan os.Signal, 1)
26 signal.Notify(sigint, syscall.SIGINT, syscall.SIGTERM)
27 <-sigint
28 signal.Stop(sigint)
29}