mirror of
https://github.com/Xevion/banner.git
synced 2025-12-06 03:14:24 -06:00
Make scrape periodic + goroutine-based
This commit is contained in:
17
main.go
17
main.go
@@ -274,11 +274,18 @@ func main() {
|
||||
log.Info().Str("term", term).Str("sessionID", sessionID).Msg("Setting selected term")
|
||||
SelectTerm(term)
|
||||
|
||||
// Scrape on startup
|
||||
err = Scrape()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Startup Scrape Failed")
|
||||
}
|
||||
// Launch a goroutine to scrape the banner system periodically
|
||||
go func() {
|
||||
for {
|
||||
err := Scrape()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Periodic Scrape Failed")
|
||||
}
|
||||
|
||||
// Wait 5 minutes
|
||||
time.Sleep(3 * time.Minute)
|
||||
}
|
||||
}()
|
||||
|
||||
// Close session, ensure http client closes idle connections
|
||||
defer session.Close()
|
||||
|
||||
Reference in New Issue
Block a user