add draft trial version of molecula

This commit is contained in:
Maxton Huff 2021-02-05 12:16:08 -06:00
parent 927db378b4
commit fec0337630
5 changed files with 67 additions and 3 deletions

View file

@ -1,4 +1,4 @@
.PHONY: build check-clean clean build-lattice cover cover-viz default docker docker-build docker-test docker-tag-push generate generate-protoc generate-pql generate-statik gometalinter install install-build-deps install-golangci-lint install-gometalinter install-protoc install-protoc-gen-gofast install-peg install-statik prerelease prerelease-upload release release-build test testv testv-race testvsub testvsub-race test-txstore-rbf lattice
.PHONY: build check-clean clean build-lattice cover cover-viz default docker docker-build docker-test docker-tag-push generate generate-protoc generate-pql generate-statik gometalinter install install-build-deps install-golangci-lint install-gometalinter install-protoc install-protoc-gen-gofast install-peg install-statik prerelease prerelease-upload release release-build test testv testv-race testvsub testvsub-race test-txstore-rbf lattice release-build-trial
CLONE_URL=github.com/pilosa/pilosa
MOD_VERSION=v2
@ -11,7 +11,7 @@ BRANCH_ID := $(BRANCH)-$(GOOS)-$(GOARCH)
BUILD_TIME := $(shell date -u +%FT%T%z)
SHARD_WIDTH = 20
COMMIT := $(shell git describe --exact-match >/dev/null 2>&1 || git rev-parse --short HEAD)
LDFLAGS="-X github.com/pilosa/pilosa/v2.Version=$(VERSION) -X github.com/pilosa/pilosa/v2.BuildTime=$(BUILD_TIME) -X github.com/pilosa/pilosa/v2.Variant=$(VARIANT) -X github.com/pilosa/pilosa/v2.Commit=$(COMMIT) -X github.com/pilosa/pilosa/v2.LatticeCommit=$(LATTICE_COMMIT)"
LDFLAGS="-X github.com/pilosa/pilosa/v2.Version=$(VERSION) -X github.com/pilosa/pilosa/v2.BuildTime=$(BUILD_TIME) -X github.com/pilosa/pilosa/v2.Variant=$(VARIANT) -X github.com/pilosa/pilosa/v2.Commit=$(COMMIT) -X github.com/pilosa/pilosa/v2.LatticeCommit=$(LATTICE_COMMIT) -X github.com/pilosa/pilosa/v2.TrialDeadline=$(TRIAL_DEADLINE)"
GO_VERSION=1.14.10
RELEASE ?= 0
RELEASE_ENABLED = $(subst 0,,$(RELEASE))
@ -98,6 +98,13 @@ cover-viz: cover
build:
go build -tags='$(BUILD_TAGS)' -ldflags $(LDFLAGS) $(FLAGS) ./cmd/pilosa
# Create a single release trial build under the build directory
release-build-trial:
$(MAKE) $(if $(DOCKER_BUILD),docker-)build FLAGS="-o build/pilosa-trial-$(VERSION_ID)/pilosa" RELEASE=1
cp NOTICE README.md build/pilosa-trial-$(VERSION_ID)
tar -cvz -C build -f build/pilosa-trial-$(VERSION_ID).tar.gz pilosa-trial-$(VERSION_ID)/
@echo Created release trial build: build/pilosa-trial-$(VERSION_ID).tar.gz
# Create a single release build under the build directory
release-build:
$(MAKE) $(if $(DOCKER_BUILD),docker-)build FLAGS="-o build/pilosa-$(VERSION_ID)/pilosa" RELEASE=1

1
go.mod
View file

@ -5,6 +5,7 @@ replace github.com/hashicorp/memberlist => github.com/pilosa/memberlist v0.1.4-0
require (
github.com/CAFxX/gcnotifier v0.0.0-20190112062741-224a280d589d
github.com/DataDog/datadog-go v0.0.0-20180822151419-281ae9f2d895
github.com/beevik/ntp v0.3.0
github.com/benbjohnson/immutable v0.3.0
github.com/cespare/xxhash v1.1.0
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect

2
go.sum
View file

@ -31,6 +31,8 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hC
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/beevik/ntp v0.3.0 h1:xzVrPrE4ziasFXgBVBZJDP0Wg/KpMwk2KHJ4Ba8GrDw=
github.com/beevik/ntp v0.3.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg=
github.com/benbjohnson/immutable v0.3.0 h1:TVRhuZx2wG9SZ0LRdqlbs9S5BZ6Y24hJEHTCgWHZEIw=
github.com/benbjohnson/immutable v0.3.0/go.mod h1:uc6OHo6PN2++n98KHLxW8ef4W42ylHiQSENghE1ezxI=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=

View file

@ -39,6 +39,7 @@ import (
"golang.org/x/sync/errgroup"
"github.com/beevik/ntp"
"github.com/pelletier/go-toml"
"github.com/pilosa/pilosa/v2"
"github.com/pilosa/pilosa/v2/boltdb"
@ -285,6 +286,16 @@ func (m *Command) SetupServer() error {
m.logger.Printf("%s", pilosa.VersionInfo())
if pilosa.TrialDeadline != "" {
layout := "2006-02-02"
pilosa.TrialDeadline = "2021-02-06"
endTime, err := time.Parse(layout, pilosa.TrialDeadline)
if err != nil {
return errors.Wrap(err, "parsing curTime from make file")
}
go m.dailyCheck(endTime)
}
// If the pilosa command line uses -tx to override the
// PILOSA_TXSRC env variable, then we must also correct
// the environment, so that pilosa/txfactory.go can determine the
@ -478,6 +489,48 @@ func (m *Command) SetupServer() error {
return errors.Wrap(err, "new handler")
}
// dailyCheck runs in the background while a trial version of Molecula is being run, displaying daily reminders of the remaining days
func (m *Command) dailyCheck(end time.Time) error {
ticker := time.NewTicker(5 * time.Second)
var err error
for range ticker.C {
cur, err := m.ntpServerTime()
if err != nil {
return errors.Wrap(err, "reading ntp server time")
}
m.logger.Printf("Current time remaining in trial: %v", end.Sub(cur))
if end.Sub(cur) <= 0 {
m.logger.Printf("end: %v", end) // test line
m.logger.Printf("cur: %v", cur) // test line
m.logger.Printf("Your free trial has ended")
os.Exit(0) //is 0 the right exit number?
}
}
return errors.Wrap(err, "reading ntp server time")
}
// ntpServerTime attempts to reach ntp servers with delays between each attempt
func (m *Command) ntpServerTime() (time.Time, error) {
curTime, err := ntp.Time("0.beevik-ntp.pool.ntp.org")
errCount := 0
if err != nil {
for i := 0; i < 4; i++ {
curTime, err = ntp.Time("0.beevik-ntp.pool.ntp.org")
if err != nil {
errCount++
if errCount >= 4 {
return curTime, err
}
time.Sleep(100 * time.Millisecond)
} else {
break
}
}
}
return curTime, err
}
// setupNetworking sets up internode communication based on the configuration.
func (m *Command) setupNetworking() error {
if m.Config.Cluster.Disabled {

View file

@ -25,6 +25,7 @@ var Variant string
var BuildTime string
var LatticeCommit string
var GoVersion string = runtime.Version()
var TrialDeadline string
func VersionInfo() string {
var prefix string
@ -52,7 +53,7 @@ func VersionInfo() string {
case buildTime != "":
suffix += " (" + buildTime + ")"
}
suffix += " " + GoVersion
suffix += " " + GoVersion + " limited time trial ends at: " + TrialDeadline
return prefix + "Pilosa" + suffix
}