mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +00:00
chasquid: Periodically reload the user databases
This patch makes chasquid periodically reload the user databases, in line with what we do for aliases.
This commit is contained in:
24
chasquid.go
24
chasquid.go
@@ -108,6 +108,8 @@ func main() {
|
|||||||
remoteC := &courier.SMTP{}
|
remoteC := &courier.SMTP{}
|
||||||
s.InitQueue(conf.DataDir+"/queue", aliasesR, localC, remoteC)
|
s.InitQueue(conf.DataDir+"/queue", aliasesR, localC, remoteC)
|
||||||
|
|
||||||
|
go s.periodicallyReload(aliasesR)
|
||||||
|
|
||||||
// Load the addresses and listeners.
|
// Load the addresses and listeners.
|
||||||
systemdLs, err := systemd.Listeners()
|
systemdLs, err := systemd.Listeners()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -155,7 +157,6 @@ func loadDomain(name, dir string, s *Server, aliasesR *aliases.Resolver) {
|
|||||||
glog.Errorf(" error: %v", err)
|
glog.Errorf(" error: %v", err)
|
||||||
} else {
|
} else {
|
||||||
s.AddUserDB(name, udb)
|
s.AddUserDB(name, udb)
|
||||||
// TODO: periodically reload the database.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,17 +271,24 @@ func (s *Server) InitQueue(path string, aliasesR *aliases.Resolver,
|
|||||||
glog.Fatalf("Error loading queue: %v", err)
|
glog.Fatalf("Error loading queue: %v", err)
|
||||||
}
|
}
|
||||||
s.queue = q
|
s.queue = q
|
||||||
|
}
|
||||||
|
|
||||||
// Launch the periodic reload of aliases, now that the queue may care
|
// periodicallyReload some of the server's information, such as aliases and
|
||||||
// about them.
|
// the user databases.
|
||||||
go func() {
|
func (s *Server) periodicallyReload(aliasesR *aliases.Resolver) {
|
||||||
for range time.Tick(30 * time.Second) {
|
for range time.Tick(30 * time.Second) {
|
||||||
err := aliasesR.Reload()
|
err := aliasesR.Reload()
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Error reloading aliases: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for domain, udb := range s.userDBs {
|
||||||
|
err = udb.Reload()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error reloading aliases: %v")
|
glog.Errorf("Error reloading %q user db: %v", domain, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) getTLSConfig() (*tls.Config, error) {
|
func (s *Server) getTLSConfig() (*tls.Config, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user