Skip to content

Commit

Permalink
Print version upon startup
Browse files Browse the repository at this point in the history
  • Loading branch information
eikendev committed Apr 11, 2022
1 parent 1a31b91 commit 3a48352
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Makefile
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion cmd/pushbits/main.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 3a48352

Please sign in to comment.