Print version upon startup

This commit is contained in:
eikendev 2022-04-11 15:47:34 +02:00
parent 1a31b91c18
commit 3a483526b6
No known key found for this signature in database
GPG key ID: A1BDB1B28C8EF694
2 changed files with 10 additions and 2 deletions

View file

@ -5,12 +5,14 @@ DOCS_DIR := ./docs
OUT_DIR := ./out
TESTS_DIR := ./tests
VERSION := `git describe --tags`
SEMGREP_MODFILE := $(TESTS_DIR)/semgrep-rules/go.mod
.PHONY: build
build:
mkdir -p $(OUT_DIR)
go build -ldflags="-w -s" -o $(OUT_DIR)/pushbits ./cmd/pushbits
go build -ldflags="-w -s -X main.Version=$(VERSION)" -o $(OUT_DIR)/pushbits ./cmd/pushbits
.PHONY: clean
clean:

View file

@ -14,6 +14,8 @@ import (
"github.com/pushbits/server/internal/runner"
)
var Version string
func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) {
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
@ -42,7 +44,11 @@ func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) {
// @securityDefinitions.basic BasicAuth
func main() {
log.Println("Starting PushBits.")
if len(Version) == 0 {
log.Panic("Version not set")
} else {
log.Printf("Starting PushBits %s", Version)
}
c := configuration.Get()