diff --git a/Makefile b/Makefile index ef6a0ca91..d7cc8daca 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,9 @@ ifeq ($(OS),Windows_NT) endif build: - $(SET) CGO_ENABLED=1 $(SEPARATOR) packr2 build -mod=vendor -v + $(eval DATE := $(shell go run scripts/getDate.go)) + $(eval GITHASH := $(shell git rev-parse HEAD)) + $(SET) CGO_ENABLED=1 $(SEPARATOR) go build -mod=vendor -v -ldflags "-X 'github.com/stashapp/stash/pkg/api.buildstamp=$(DATE)' -X 'github.com/stashapp/stash/pkg/api.githash=$(GITHASH)'" install: packr2 install @@ -35,3 +37,4 @@ lint: .PHONY: ui ui: cd ui/v2 && yarn build + packr2 diff --git a/pkg/api/server.go b/pkg/api/server.go index 65454f704..fd1112a29 100644 --- a/pkg/api/server.go +++ b/pkg/api/server.go @@ -5,6 +5,15 @@ import ( "crypto/tls" "errors" "fmt" + "io/ioutil" + "net/http" + "os" + "path" + "path/filepath" + "runtime/debug" + "strconv" + "strings" + "github.com/99designs/gqlgen/handler" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" @@ -16,16 +25,11 @@ import ( "github.com/stashapp/stash/pkg/manager/paths" "github.com/stashapp/stash/pkg/models" "github.com/stashapp/stash/pkg/utils" - "io/ioutil" - "net/http" - "os" - "path" - "path/filepath" - "runtime/debug" - "strconv" - "strings" ) +var buildstamp string = "" +var githash string = "" + var uiBox *packr.Box //var legacyUiBox *packr.Box @@ -154,6 +158,7 @@ func Start() { } go func() { + printVersion() logger.Infof("stash is running on HTTPS at https://" + address + "/") logger.Fatal(httpsServer.ListenAndServeTLS("", "")) }() @@ -164,12 +169,17 @@ func Start() { } go func() { + printVersion() logger.Infof("stash is running on HTTP at http://" + address + "/") logger.Fatal(server.ListenAndServe()) }() } } +func printVersion() { + fmt.Printf("stash version: %s (%s)\n", githash, buildstamp) +} + func makeTLSConfig() *tls.Config { cert, err := ioutil.ReadFile(paths.GetSSLCert()) if err != nil { diff --git a/scripts/getDate.go b/scripts/getDate.go new file mode 100644 index 000000000..6afa863c2 --- /dev/null +++ b/scripts/getDate.go @@ -0,0 +1,12 @@ +// +build ignore + +package main + +import "fmt" +import "time" + +func main() { + now := time.Now().Format("2006-01-02 15:04:05") + + fmt.Printf("%s", now) +}