mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
Support reloading ACLs with SIGHUP
Also continously listen for signals, not just once.
This commit is contained in:
parent
36dca3516a
commit
2feed18b28
1 changed files with 36 additions and 23 deletions
13
app.go
13
app.go
|
@ -728,6 +728,7 @@ func (h *Headscale) Serve() error {
|
|||
syscall.SIGHUP)
|
||||
go func(c chan os.Signal) {
|
||||
// Wait for a SIGINT or SIGKILL:
|
||||
for {
|
||||
sig := <-c
|
||||
switch sig {
|
||||
case syscall.SIGHUP:
|
||||
|
@ -737,6 +738,17 @@ func (h *Headscale) Serve() error {
|
|||
|
||||
// TODO(kradalby): Reload config on SIGHUP
|
||||
|
||||
if h.cfg.ACL.PolicyPath != "" {
|
||||
aclPath := AbsolutePathFromConfigPath(h.cfg.ACL.PolicyPath)
|
||||
err := h.LoadACLPolicy(aclPath)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to reload ACL policy")
|
||||
}
|
||||
log.Info().
|
||||
Str("path", aclPath).
|
||||
Msg("ACL policy successfully reloaded")
|
||||
}
|
||||
|
||||
default:
|
||||
log.Info().
|
||||
Str("signal", sig.String()).
|
||||
|
@ -758,6 +770,7 @@ func (h *Headscale) Serve() error {
|
|||
// And we're done:
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
}(sigc)
|
||||
|
||||
return errorGroup.Wait()
|
||||
|
|
Loading…
Reference in a new issue