mirror of
https://github.com/benbusby/farside.git
synced 2025-03-13 10:46:35 -04:00
Allow skipping instance checks for particular services
Some checks are pending
Tests / test (1.21.x, macos-latest) (push) Waiting to run
Tests / test (1.21.x, ubuntu-latest) (push) Waiting to run
Tests / test (1.21.x, windows-latest) (push) Waiting to run
Tests / test (1.22.x, macos-latest) (push) Waiting to run
Tests / test (1.22.x, ubuntu-latest) (push) Waiting to run
Tests / test (1.22.x, windows-latest) (push) Waiting to run
Tests / test (1.23.x, macos-latest) (push) Waiting to run
Tests / test (1.23.x, ubuntu-latest) (push) Waiting to run
Tests / test (1.23.x, windows-latest) (push) Waiting to run
Some checks are pending
Tests / test (1.21.x, macos-latest) (push) Waiting to run
Tests / test (1.21.x, ubuntu-latest) (push) Waiting to run
Tests / test (1.21.x, windows-latest) (push) Waiting to run
Tests / test (1.22.x, macos-latest) (push) Waiting to run
Tests / test (1.22.x, ubuntu-latest) (push) Waiting to run
Tests / test (1.22.x, windows-latest) (push) Waiting to run
Tests / test (1.23.x, macos-latest) (push) Waiting to run
Tests / test (1.23.x, ubuntu-latest) (push) Waiting to run
Tests / test (1.23.x, windows-latest) (push) Waiting to run
Services like searxng don't need to have instance checks performed since the nightly cron task filters out the instances already.
This commit is contained in:
parent
99e5dfcac2
commit
d15e05d39e
17
db/cron.go
17
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
|
||||
|
||||
|
@ -47,7 +47,6 @@ func GetServicesFileName() string {
|
||||
return serviceJSON
|
||||
}
|
||||
|
||||
|
||||
func FetchServicesFile(serviceJSON string) ([]byte, error) {
|
||||
resp, err := http.Get(baseRepoLink + serviceJSON)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user