mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 08:53: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)
|
syscall.SIGHUP)
|
||||||
go func(c chan os.Signal) {
|
go func(c chan os.Signal) {
|
||||||
// Wait for a SIGINT or SIGKILL:
|
// Wait for a SIGINT or SIGKILL:
|
||||||
|
for {
|
||||||
sig := <-c
|
sig := <-c
|
||||||
switch sig {
|
switch sig {
|
||||||
case syscall.SIGHUP:
|
case syscall.SIGHUP:
|
||||||
|
@ -737,6 +738,17 @@ func (h *Headscale) Serve() error {
|
||||||
|
|
||||||
// TODO(kradalby): Reload config on SIGHUP
|
// 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:
|
default:
|
||||||
log.Info().
|
log.Info().
|
||||||
Str("signal", sig.String()).
|
Str("signal", sig.String()).
|
||||||
|
@ -758,6 +770,7 @@ func (h *Headscale) Serve() error {
|
||||||
// And we're done:
|
// And we're done:
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}(sigc)
|
}(sigc)
|
||||||
|
|
||||||
return errorGroup.Wait()
|
return errorGroup.Wait()
|
||||||
|
|
Loading…
Reference in a new issue