diff options
| author | Ben Busby <contact@benbusby.com> | 2025-02-25 17:21:05 -0700 |
|---|---|---|
| committer | Ben Busby <contact@benbusby.com> | 2025-02-25 17:21:05 -0700 |
| commit | d15e05d39ea7fec7f8f975e8aebaf7e8c9ce5b94 (patch) | |
| tree | 3ad5f6c6551ce00adfc562fd86a8991266516ff1 /db | |
| parent | 99e5dfcac221b7ef1653144b23b6b6455ce452a5 (diff) | |
| download | farside-d15e05d39ea7fec7f8f975e8aebaf7e8c9ce5b94.tar.gz | |
Allow skipping instance checks for particular services
Services like searxng don't need to have instance checks performed since
the nightly cron task filters out the instances already.
Diffstat (limited to 'db')
| -rw-r--r-- | db/cron.go | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -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 |
