diff --git a/init/guildgate.service b/init/guildgate.service index 1fedc4c..04757cd 100644 --- a/init/guildgate.service +++ b/init/guildgate.service @@ -2,12 +2,15 @@ Description=Guildgate: A web front-end for LDAP After=network.target StartLimitIntervalSec=0 + [Service] Type=simple Restart=always RestartSec=1 User=root ExecStart=/usr/local/bin/guildgate +ExecReload=/bin/kill -HUP $MAINPID + [Install] WantedBy=multi-user.target diff --git a/main.go b/main.go index 0cf0f1f..6c877ed 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,9 @@ package main import ( "log" "net/http" + "os" + "os/signal" + "syscall" "text/template" "github.com/gorilla/mux" @@ -59,6 +62,18 @@ func main() { } passwordTokenSet = make(map[string]bool) log.Printf("Guildgate v%v starting on %v\n", version, Conf.Port) + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGUSR1) + go func() { + for { + <-sigs + log.Println("reloading templates on SIGUSR1") + tpl = template.Must(template.ParseGlob(Conf.TplPath + "/*")) + if Conf.UserTplPath != "" { + tpl = template.Must(tpl.ParseGlob(Conf.UserTplPath + "/*")) + } + } + }() if Conf.Tls { log.Printf("Starting TLS\n") if Conf.Cert == "" {