mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-27 20:45:56 +00:00
domaininfo: Reload periodically
This patch makes chasquid reload domaininfo periodically, so it notices any external changes made to it. It is in line with what we do for aliases and authentication already, and makes it possible for external removals an additions to the domaininfo database to be picked up without a restart.
This commit is contained in:
@@ -38,11 +38,22 @@ func New(dir string) (*DB, error) {
|
||||
}
|
||||
l.ev = trace.NewEventLog("DomainInfo", dir)
|
||||
|
||||
err = l.Reload()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
||||
|
||||
// Load the database from disk; should be called once at initialization.
|
||||
func (db *DB) Load() error {
|
||||
// Reload the database from disk.
|
||||
func (db *DB) Reload() error {
|
||||
db.Lock()
|
||||
defer db.Unlock()
|
||||
|
||||
// Clear the map, in case it has data.
|
||||
db.info = map[string]*Domain{}
|
||||
|
||||
ids, err := db.store.ListIDs()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user