mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
update conf on start
This commit is contained in:
parent
122df895d1
commit
1616766b4b
1 changed files with 14 additions and 7 deletions
|
@ -66,19 +66,26 @@ func (s *service) Run(_ context.Context) (err error) {
|
||||||
func (s *service) updateLoop(ctx context.Context) {
|
func (s *service) updateLoop(ctx context.Context) {
|
||||||
ticker := time.NewTicker(time.Minute * 10)
|
ticker := time.NewTicker(time.Minute * 10)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
updateConf := func() {
|
||||||
|
err := s.updateConfiguration(ctx)
|
||||||
|
if err != nil {
|
||||||
|
if err == ErrConfigurationNotChanged {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Info("can't update configuration", zap.Error(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateConf()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-s.updateCtx.Done():
|
case <-s.updateCtx.Done():
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
}
|
}
|
||||||
err := s.updateConfiguration(ctx)
|
updateConf()
|
||||||
if err != nil {
|
|
||||||
if err == ErrConfigurationNotChanged {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Info("can't update configuration", zap.Error(err))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue