Enha: tx for cron

This commit is contained in:
Grail Finder
2025-07-04 12:25:20 +03:00
parent 71a2d9d747
commit c2d6812230
5 changed files with 38 additions and 41 deletions

View File

@ -62,20 +62,16 @@ func main() {
// Setup graceful shutdown
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
repo := repos.NewRepoProvider(cfg.DBPath)
defer repo.Close()
cm := crons.NewCronManager(repo, slog.Default())
cm.Start()
server := ListenToRequests(cfg.ServerConfig.Port)
go func() {
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
panic(err)
}
}()
<-stop
slog.Info("Shutting down server...")
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)