feat: add skill management service
This commit is contained in:
32
internal/service/updater.go
Normal file
32
internal/service/updater.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s *Service) StartAutoUpdate(ctx context.Context) {
|
||||
go func() {
|
||||
cfg, err := s.LoadConfig()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if cfg.Update.CheckOnStartup {
|
||||
_ = s.RunAutoUpdate(ctx)
|
||||
}
|
||||
interval := cfg.Update.IntervalMinutes
|
||||
if interval <= 0 {
|
||||
interval = 60
|
||||
}
|
||||
ticker := time.NewTicker(time.Duration(interval) * time.Minute)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
_ = s.RunAutoUpdate(ctx)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user