feat: add basic workings

This commit is contained in:
2026-04-29 23:38:43 +02:00
parent da3dee9ae7
commit 76c893ae7e
14 changed files with 167 additions and 112 deletions
+19 -1
View File
@@ -28,22 +28,40 @@ func Kickoff(env bootstrap.Environment, db *gorm.DB) {
run(env, db)
running := false
for range ticker.C {
run(env, db)
if running {
slog.Warn("watchdog is still running, skipping tick")
continue
}
running = true
func() {
defer func() { running = false }()
run(env, db)
}()
}
}()
}
// the watchdog has 2 tasks
// 1 revoke expires keys
// 2 remove / sync orphaned files/db records
func run(env bootstrap.Environment, db *gorm.DB) {
slog.Debug("watchdog cycle start")
revokeExpired(db)
fsState, err := scanFS(env)
if err != nil {
slog.Error("scanFS failed", "error", err)
return
}
dbState, err := scanDB(db)
if err != nil {
slog.Error("scanDB failed", "error", err)
return
}