Exit updateArchives gracefully

This commit is contained in:
Daniele Tonon
2023-07-27 23:37:25 +02:00
parent dcf8e3a451
commit f3781c1f76

13
main.go
View File

@@ -3,6 +3,7 @@ package main
import (
"context"
"embed"
"fmt"
"html"
"net/http"
"os"
@@ -34,9 +35,15 @@ var (
func updateArchives(ctx context.Context) {
for {
loadNpubsArchive(ctx)
loadRelaysArchive(ctx)
// Wait for 24 hours before executing the function again
select {
// Check for the cancellation signal.
case <-ctx.Done():
fmt.Println("Exit updateArchives gracefully...")
return
default:
loadNpubsArchive(ctx)
loadRelaysArchive(ctx)
}
time.Sleep(24 * time.Hour)
}
}