package main import ( "context" "os" "os/signal" "syscall" "time" "go.cryptoscope.co/ssb/sbot" ) func main() { sbotOpts := []sbot.Option{ sbot.DisableEBT(true), sbot.DisableLegacyLiveReplication(false), sbot.EnableAdvertismentBroadcasts(true), sbot.EnableAdvertismentDialing(true), sbot.LateOption(sbot.WithUNIXSocket()), sbot.WithHops(3), sbot.WithListenAddr(":8009"), sbot.WithWebsocketAddress(":8988"), } pub, err := sbot.New(sbotOpts...) if err != nil { panic(err) } c := make(chan os.Signal) signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { <-c pub.Shutdown() time.Sleep(2 * time.Second) err := pub.Close() if err != nil { panic(err) } time.Sleep(2 * time.Second) os.Exit(0) }() for { ctx := context.TODO() err = pub.Network.Serve(ctx) if err != nil { panic(err) } time.Sleep(1 * time.Second) select { case <-ctx.Done(): err := pub.Close() if err != nil { panic(err) } default: } } }