this repo has no description
1package watcher
2
3import (
4 "fmt"
5 "time"
6
7 "github.com/aottr/nox/internal/cache"
8 "github.com/aottr/nox/internal/config"
9 "github.com/aottr/nox/internal/logging"
10 "github.com/aottr/nox/internal/processor"
11)
12
13func Start(cfg *config.Config) {
14 log := logging.Get()
15 logging.SetLevel("debug")
16 ticker := time.NewTicker(cfg.Interval)
17 defer ticker.Stop()
18
19 ctx, err := config.BuildRuntimeCtxFromConfig(cfg)
20 if err != nil {
21 log.Error("error building runtime context", "error", err.Error())
22 return
23 }
24 log.Info(fmt.Sprintf("Starting watcher (interval: %s)\n", cfg.Interval))
25
26 for {
27 if err := cache.GlobalCache.RefreshCache(); err != nil {
28 log.Error("error pre-fetching secrets", "error", err.Error())
29 }
30 if err := processor.SyncApps(ctx); err != nil {
31 log.Error("error syncing secrets", "error", err.Error())
32 }
33 <-ticker.C
34 }
35}