summaryrefslogtreecommitdiff
path: root/db/cron.go
diff options
context:
space:
mode:
Diffstat (limited to 'db/cron.go')
-rw-r--r--db/cron.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/db/cron.go b/db/cron.go
index 7b7e9ce..4f0f2dc 100644
--- a/db/cron.go
+++ b/db/cron.go
@@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
+ "slices"
"strings"
"time"
@@ -18,9 +19,14 @@ const defaultPrimary = "https://farside.link/state"
const defaultCFPrimary = "https://cf.farside.link/state"
var LastUpdate time.Time
+var skipInstanceChecks = []string{
+ "searx",
+ "searxng",
+}
func InitCronTasks() {
log.Println("Initializing cron tasks...")
+ updateServiceList()
cronDisabled := os.Getenv("FARSIDE_CRON")
if len(cronDisabled) == 0 || cronDisabled == "1" {
@@ -58,6 +64,8 @@ func queryServiceInstances() {
}
for _, service := range services.ServiceList {
+ canSkip := slices.Contains[[]string, string](skipInstanceChecks, service.Type)
+
fmt.Printf("===== %s =====\n", service.Type)
var instances []string
for _, instance := range service.Instances {
@@ -68,7 +76,7 @@ func queryServiceInstances() {
available := queryServiceInstance(
instance,
testURL,
- )
+ canSkip)
if available {
instances = append(instances, instance)
@@ -105,12 +113,17 @@ func fetchInstancesFromPrimary() ([]services.Service, error) {
return serviceList, err
}
-func queryServiceInstance(instance, testURL string) bool {
+func queryServiceInstance(instance, testURL string, canSkipCheck bool) bool {
testMode := os.Getenv("FARSIDE_TEST")
if len(testMode) > 0 && testMode == "1" {
return true
}
+ if canSkipCheck {
+ fmt.Printf(" [INFO] Adding %s\n", instance)
+ return true
+ }
+
ua := "Mozilla/5.0 (compatible; Farside/1.0.0; +https://farside.link)"
url := instance + testURL