Get an ever updating ics link for all the events you RSVP to on the Atmosphere whenslunch.app
0

Configure Feed

Select the types of activity you want to include in your feed.

whens-lunch / cmd / main.go
1.8 kB 79 lines
1package main 2 3import ( 4 "context" 5 "log/slog" 6 "os" 7 "os/signal" 8 "sync" 9 "syscall" 10 "time" 11 12 "github.com/bluesky-social/indigo/atproto/identity" 13 "github.com/spf13/viper" 14 "tangled.org/pds.dad/whens-lunch/backfill" 15 "tangled.org/pds.dad/whens-lunch/config" 16 "tangled.org/pds.dad/whens-lunch/database" 17 listener "tangled.org/pds.dad/whens-lunch/listener" 18 server "tangled.org/pds.dad/whens-lunch/server" 19) 20 21func main() { 22 config.Load() 23 ctx, cancel := context.WithCancel(context.Background()) 24 defer cancel() 25 26 db, err := database.SetupDatabase() 27 if err != nil { 28 slog.Error("database setup", "err", err) 29 os.Exit(1) 30 } 31 32 plcURL := viper.GetString("identity.plc_url") 33 bdir := identity.BaseDirectory{ 34 PLCURL: plcURL, 35 TryAuthoritativeDNS: false, 36 SkipDNSDomainSuffixes: []string{".bsky.social"}, 37 } 38 cdir := identity.NewCacheDirectory(&bdir, 500, time.Hour*24, time.Minute*2, time.Minute*5) 39 40 // Trap shutdown signals 41 sigCh := make(chan os.Signal, 1) 42 signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) 43 go func() { 44 <-sigCh 45 slog.Info("shutting down...") 46 cancel() 47 }() 48 49 // If either of these exits, cancel the shared context so the other one winds down too instead 50 // of leaving the process half-alive. 51 var wg sync.WaitGroup 52 53 repoManager := backfill.NewRepoManager(slog.Default(), db, cdir) 54 listener := listener.NewListener(db, repoManager) 55 wg.Go(func() { 56 defer cancel() 57 listener.Run(ctx) 58 }) 59 60 wg.Go(func() { 61 defer cancel() 62 server.RunHTTPServer(ctx, db, cdir) 63 }) 64 65 backfill := backfill.NewBackfill(db, slog.Default(), cdir) 66 wg.Go(func() { 67 defer cancel() 68 backfill.Run(ctx) 69 }) 70 71 wg.Wait() 72 73 // Flush the WAL before exiting 74 if err := database.Checkpoint(db); err != nil { 75 slog.Error("checkpoint", "err", err) 76 } 77 78 slog.Info("bye") 79}