feat(cmd,compose):lab4 run reconciler under postgres advisory lock

This commit is contained in:
Голиков Maximillian Антон
2026-10-23 10:32:08 +03:00
parent 43ef67ae7e
commit 6c78efa17d
2 changed files with 21 additions and 1 deletions
+18 -1
View File
@@ -78,6 +78,10 @@ func main() {
Region: cfg.S3Region,
})
if err != nil {
var unavailable *domain.UnavailableError
if errors.As(err, &unavailable) {
log.Fatalf("s3: %v (reason: %s)", err, unavailable.Reason)
}
log.Fatalf("s3: %v", err)
}
@@ -114,8 +118,20 @@ func main() {
srv := &http.Server{Addr: addr, Handler: router}
reconcilerCtx, reconcilerCancel := context.WithCancel(context.Background())
defer reconcilerCancel()
if cfg.ReconcilerEnabled {
reconciler := service.NewReconciler(
store.Attachments(),
objectStorage,
pool,
cfg.ReconcilerGracePeriod,
)
go reconciler.Run(reconcilerCtx, cfg.ReconcilerInterval)
}
go func() {
log.Printf("Запускаем на %s (SESSION_STORE=%s)", addr, cfg.SessionStore)
log.Printf("Запускаем на %s (SESSION_STORE=%s, RECONCILER_ENABLED=%v)", addr, cfg.SessionStore, cfg.ReconcilerEnabled)
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Fatalf("Ошибка запуска: %v", err)
}
@@ -127,6 +143,7 @@ func main() {
log.Printf("Получен сигнал завершения; readiness выключен, drain %s", cfg.ShutdownDrain)
ready.Store(false)
reconcilerCancel()
if cfg.ShutdownDrain > 0 {
time.Sleep(cfg.ShutdownDrain)