diff --git a/Makefile b/Makefile index 029db807d1..e17d4862d3 100644 --- a/Makefile +++ b/Makefile @@ -83,9 +83,16 @@ binlog: @echo "Building binlog ..." @mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/binlog $(PWD)/cmd/binlog/main.go 1>/dev/null +BUILD_TAGS = $(shell git describe --tags --always --dirty="-dev") +BUILD_TIME = $(shell date) +GIT_COMMIT = $(shell git rev-parse --short HEAD) +GO_VERSION = $(shell go version) + milvus: build-cpp @echo "Building Milvus ..." - @mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/milvus $(PWD)/cmd/main.go 1>/dev/null + @mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build \ + -ldflags="-X 'main.BuildTags=$(BUILD_TAGS)' -X 'main.BuildTime=$(BUILD_TIME)' -X 'main.GitCommit=$(GIT_COMMIT)' -X 'main.GoVersion=$(GO_VERSION)'" \ + -o $(INSTALL_PATH)/milvus $(PWD)/cmd/main.go 1>/dev/null build-go: milvus diff --git a/cmd/main.go b/cmd/main.go index d2e5deda13..3ae7f34e01 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -37,6 +37,28 @@ const ( roleStandalone = "standalone" ) +var ( + BuildTags = "unknown" + BuildTime = "unknown" + GitCommit = "unknown" + GoVersion = "unknown" +) + +func printBanner() { + fmt.Println() + fmt.Println(" __ _________ _ ____ ______ ") + fmt.Println(" / |/ / _/ /| | / / / / / __/ ") + fmt.Println(" / /|_/ // // /_| |/ / /_/ /\\ \\ ") + fmt.Println(" /_/ /_/___/____/___/\\____/___/ ") + fmt.Println() + fmt.Println("Welcome to use Milvus!") + fmt.Println("Version: " + BuildTags) + fmt.Println("Built: " + BuildTime) + fmt.Println("GitCommit: " + GitCommit) + fmt.Println("GoVersion: " + GoVersion) + fmt.Println() +} + func getPidFileName(serverType string, alias string) string { var filename string if len(alias) != 0 { @@ -239,6 +261,7 @@ func main() { filename := getPidFileName(serverType, svrAlias) switch command { case "run": + printBanner() fd, err := createPidFile(filename, runtimeDir) if err != nil { panic(err)