diff --git a/.circleci/config.yml b/.circleci/config.yml index 1b2fd74..1ce59cb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,6 +5,6 @@ jobs: steps: - checkout - run: | - make test -# - store_artifacts: -# path: output + make dist + - store_artifacts: + path: output diff --git a/.gitignore b/.gitignore index eab603e..3b5cd0c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ fediverse-archive +output/ diff --git a/Makefile b/Makefile index 124022b..33bb1f7 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,13 @@ VERSION := $(shell git rev-parse --short HEAD) BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ') +BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ') BUILDUSER := $(shell whoami) BUILDHOST := $(shell hostname -s) BUILDARCH := $(shell uname -m) +FN := fediverse-archive +IMAGENAME := sneak/$(FN) + GOLDFLAGS += -X main.Version=$(VERSION) GOLDFLAGS += -X main.Buildtime=$(BUILDTIME) GOLDFLAGS += -X main.Builduser=$(BUILDUSER)@$(BUILDHOST) @@ -13,18 +17,25 @@ GOFLAGS = -ldflags "$(GOLDFLAGS)" default: rundebug rundebug: build - ./fediverse-archive -debug + ./$(FN) -debug run: build - ./fediverse-archvie + ./$(FN) -build: ./fediverse-archive +build: ./$(FN) -./fediverse-archive: *.go +./$(FN): *.go go build -o $@ $(GOFLAGS) . fmt: go fmt *.go -test: - docker build -t sneak/fediverse-archive . +test: build-docker-image + +build-docker-image: + docker build -t $(IMAGENAME) . + +dist: build-docker-image + -mkdir -p ./output + docker run --rm --entrypoint cat $(IMAGENAME) /bin/$(FN) > output/$(FN) + docker save $(IMAGENAME) | bzip2 > output/$(BUILDTIMEFILENAME).$(FN).tbz2 diff --git a/locator.go b/locator.go index 0238f2f..e4c9a6c 100644 --- a/locator.go +++ b/locator.go @@ -12,6 +12,9 @@ const mastodonIndexUrl = "https://instances.social/list.json?q%5Busers%5D=&q%5Bs var foreverago = time.Now().Add((-1 * 86400 * 365 * 100) * time.Second) +// check with indices only hourly +var INDEX_CHECK_INTERVAL = time.Second * 60 * 60 + // thank fuck for https://mholt.github.io/json-to-go/ otherwise // this would have been a giant pain in the dick type MastodonIndexResponse struct { @@ -105,7 +108,7 @@ func (i *InstanceLocator) Locate() { log.Debug().Str("lastpleromaupdate", i.pleromaIndexLastRefresh.Format(time.RFC3339)).Send() i.locateMastodon() i.locatePleroma() - time.Sleep(30 * time.Second) + time.Sleep(120 * time.Second) i.instanceReport() }