reload templates on USR1
This commit is contained in:
parent
b448a91d55
commit
c147c217de
@ -2,12 +2,15 @@
|
|||||||
Description=Guildgate: A web front-end for LDAP
|
Description=Guildgate: A web front-end for LDAP
|
||||||
After=network.target
|
After=network.target
|
||||||
StartLimitIntervalSec=0
|
StartLimitIntervalSec=0
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=1
|
RestartSec=1
|
||||||
User=root
|
User=root
|
||||||
ExecStart=/usr/local/bin/guildgate
|
ExecStart=/usr/local/bin/guildgate
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
15
main.go
15
main.go
@ -3,6 +3,9 @@ package main
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
@ -59,6 +62,18 @@ func main() {
|
|||||||
}
|
}
|
||||||
passwordTokenSet = make(map[string]bool)
|
passwordTokenSet = make(map[string]bool)
|
||||||
log.Printf("Guildgate v%v starting on %v\n", version, Conf.Port)
|
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 {
|
if Conf.Tls {
|
||||||
log.Printf("Starting TLS\n")
|
log.Printf("Starting TLS\n")
|
||||||
if Conf.Cert == "" {
|
if Conf.Cert == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user