From 092b7c919b0693ce95321c1a497e1e0d8e1ce2af Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sat, 1 Mar 2014 20:46:10 -0700 Subject: [PATCH] added git revision to the binary for debugging purposes --- Makefile | 4 +++- cmd/droned/drone.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 83898753c..f5d6a87c7 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +SHA := $(shell git rev-parse --short HEAD) +BRANCH := $(shell git rev-parse --abbrev-ref HEAD) all: embed build @@ -32,7 +34,7 @@ embed: build: cd cmd/drone && go build -o ../../bin/drone - cd cmd/droned && go build -o ../../bin/droned + cd cmd/droned && go build -ldflags "-X main.version $(SHA)" -o ../../bin/droned test: go test -v github.com/drone/drone/pkg/build diff --git a/cmd/droned/drone.go b/cmd/droned/drone.go index 27f05f7d8..2faea532a 100644 --- a/cmd/droned/drone.go +++ b/cmd/droned/drone.go @@ -46,6 +46,9 @@ var ( // build will timeout after N milliseconds. // this will default to 500 minutes (6 hours) timeout time.Duration + + // commit sha for the current build. + version string ) func main() { @@ -67,6 +70,9 @@ func main() { setupStatic() setupHandlers() + // debug + log.Printf("starting drone version %s on port %s\n", version, port) + // start webserver using HTTPS or HTTP if sslcert != "" && sslkey != "" { panic(http.ListenAndServeTLS(port, sslcert, sslkey, nil))