From d9c24d3d38eaf9b2da4bcd5d042d8691b697e7dc Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Wed, 18 Oct 2023 06:20:04 -0400 Subject: cmd/sapientwindex: retry scanning in a loop So apparently this bot was randomly exiting with status code 0. I checked the vendor closure of the library and found out that this was not an intentional call made in any of the code I'm calling. Nope. Turns out this is everything working as intended because when execution gets to the end of `func main`, Go inserts a `syscall.Exit(0)` for you. This was fixed by inserting a "wait 5 seconds after each retry" loop. If this becomes a problem, I'll probably switch to using /x/cardio to have it float between 30 seconds and an hour. Signed-off-by: Xe Iaso --- cmd/sapientwindex/main.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'cmd') diff --git a/cmd/sapientwindex/main.go b/cmd/sapientwindex/main.go index 97d89a9..f13d820 100644 --- a/cmd/sapientwindex/main.go +++ b/cmd/sapientwindex/main.go @@ -38,14 +38,18 @@ func main() { Logger: slog.NewLogLogger(slog.Default().Handler(), slog.LevelInfo), } - stop, wait, err := graw.Scan(announce, handle, scriptCfg) - if err != nil { - log.Fatal(err) - } + for { + stop, wait, err := graw.Scan(announce, handle, scriptCfg) + if err != nil { + log.Fatal(err) + } + + defer stop() - defer stop() + wait() - wait() + time.Sleep(5 * time.Second) + } } type announcer struct{} -- cgit v1.2.3