+ clients: re-read auto-clients from /etc/hosts when SIGHUP is received
This commit is contained in:
parent
e5db33705d
commit
fa2f793ac7
|
@ -107,6 +107,12 @@ func (clients *clientsContainer) Init(objects []clientObject, dhcpServer *dhcpd.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reload - reload auto-clients
|
||||||
|
func (clients *clientsContainer) Reload() {
|
||||||
|
clients.addFromHostsFile()
|
||||||
|
clients.addFromSystemARP()
|
||||||
|
}
|
||||||
|
|
||||||
type clientObject struct {
|
type clientObject struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Tags []string `yaml:"tags"`
|
Tags []string `yaml:"tags"`
|
||||||
|
@ -194,8 +200,7 @@ func (clients *clientsContainer) WriteDiskConfig(objects *[]clientObject) {
|
||||||
|
|
||||||
func (clients *clientsContainer) periodicUpdate() {
|
func (clients *clientsContainer) periodicUpdate() {
|
||||||
for {
|
for {
|
||||||
clients.addFromHostsFile()
|
clients.Reload()
|
||||||
clients.addFromSystemARP()
|
|
||||||
time.Sleep(clientsUpdatePeriod)
|
time.Sleep(clientsUpdatePeriod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
home/home.go
11
home/home.go
|
@ -116,10 +116,19 @@ func Main(version string, channel string, armVer string) {
|
||||||
Context.appSignalChannel = make(chan os.Signal)
|
Context.appSignalChannel = make(chan os.Signal)
|
||||||
signal.Notify(Context.appSignalChannel, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT)
|
signal.Notify(Context.appSignalChannel, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT)
|
||||||
go func() {
|
go func() {
|
||||||
<-Context.appSignalChannel
|
for {
|
||||||
|
sig := <-Context.appSignalChannel
|
||||||
|
log.Info("Received signal '%s'", sig)
|
||||||
|
switch sig {
|
||||||
|
case syscall.SIGHUP:
|
||||||
|
Context.clients.Reload()
|
||||||
|
|
||||||
|
default:
|
||||||
cleanup()
|
cleanup()
|
||||||
cleanupAlways()
|
cleanupAlways()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// run the protection
|
// run the protection
|
||||||
|
|
Loading…
Reference in New Issue