From 3e6ee35b75157ed24ea21a948aa871f4f5de47cd Mon Sep 17 00:00:00 2001 From: Matt Reiferson Date: Wed, 1 May 2013 21:03:15 -0400 Subject: [PATCH 1/2] add GOFLAGS option to Makefile --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1c2e92c69..0f7652183 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ PREFIX=/usr/local DESTDIR= +GOFLAGS= BINDIR=${PREFIX}/bin DATADIR=${PREFIX}/share @@ -20,7 +21,7 @@ all: $(BINARIES) $(EXAMPLES) $(BLDDIR)/%: mkdir -p $(dir $@) - cd $* && go build -o $(abspath $@) + cd $* && go build ${GOFLAGS} -o $(abspath $@) $(BINARIES): %: $(BLDDIR)/% $(EXAMPLES): %: $(BLDDIR)/examples/% From e3bec659965689677f8fc120de0efcd66f84566c Mon Sep 17 00:00:00 2001 From: Matt Reiferson Date: Wed, 1 May 2013 21:03:29 -0400 Subject: [PATCH 2/2] add golang runtime version to daemon version output --- examples/nsq_to_http/nsq_to_http.go | 2 +- nsqadmin/nsqadmin.go | 5 ++++- nsqd/http.go | 2 +- nsqd/main.go | 4 ++-- nsqlookupd/main.go | 4 ++-- util/binary_version.go | 9 +++++++++ 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/examples/nsq_to_http/nsq_to_http.go b/examples/nsq_to_http/nsq_to_http.go index 1312fe1a9..c837949be 100644 --- a/examples/nsq_to_http/nsq_to_http.go +++ b/examples/nsq_to_http/nsq_to_http.go @@ -41,7 +41,7 @@ var ( throttleFraction = flag.Float64("throttle-fraction", 1.0, "publish only a fraction of messages") httpTimeoutMs = flag.Int("http-timeout-ms", 20000, "timeout for HTTP connect/read/write (each)") statusEvery = flag.Int("status-every", 250, "the # of requests between logging status (per handler), 0 disables") - maxBackoffDuration = flag.Duration("max-backoff-duration", 120 * time.Second, "the maximum backoff duration") + maxBackoffDuration = flag.Duration("max-backoff-duration", 120*time.Second, "the maximum backoff duration") getAddrs = util.StringArray{} postAddrs = util.StringArray{} nsqdTCPAddrs = util.StringArray{} diff --git a/nsqadmin/nsqadmin.go b/nsqadmin/nsqadmin.go index 9688b5240..eb477bfba 100644 --- a/nsqadmin/nsqadmin.go +++ b/nsqadmin/nsqadmin.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "github.com/bitly/nsq/util" "log" "net" @@ -33,8 +34,8 @@ func main() { flag.Parse() - log.Printf("nsqadmin v%s", util.BINARY_VERSION) if *showVersion { + fmt.Println(util.Version("nsqadmin")) return } @@ -59,6 +60,8 @@ func main() { log.Fatalf("use --nsqd-http-address or --lookupd-http-address not both") } + log.Println(util.Version("nsqadmin")) + exitChan := make(chan int) signalChan := make(chan os.Signal, 1) diff --git a/nsqd/http.go b/nsqd/http.go index 2abdb658f..55dc6f8c0 100644 --- a/nsqd/http.go +++ b/nsqd/http.go @@ -379,7 +379,7 @@ func statsHandler(w http.ResponseWriter, req *http.Request) { now := time.Now() if !jsonFormat { - io.WriteString(w, fmt.Sprintf("nsqd v%s\n", util.BINARY_VERSION)) + io.WriteString(w, fmt.Sprintf("%s\n", util.Version("nsqd"))) } stats := nsqd.getStats() diff --git a/nsqd/main.go b/nsqd/main.go index 52fdda058..711459197 100644 --- a/nsqd/main.go +++ b/nsqd/main.go @@ -57,7 +57,7 @@ func main() { } if *showVersion { - fmt.Printf("nsqd v%s\n", util.BINARY_VERSION) + fmt.Println(util.Version("nsqd")) return } @@ -81,7 +81,7 @@ func main() { *broadcastAddress = hostname } - log.Printf("nsqd v%s", util.BINARY_VERSION) + log.Println(util.Version("nsqd")) log.Printf("worker id %d", *workerId) exitChan := make(chan int) diff --git a/nsqlookupd/main.go b/nsqlookupd/main.go index 88244261c..46a0b6b32 100644 --- a/nsqlookupd/main.go +++ b/nsqlookupd/main.go @@ -37,7 +37,7 @@ func main() { } if *showVersion { - fmt.Printf("nsqlookupd v%s\n", util.BINARY_VERSION) + fmt.Println(util.Version("nsqlookupd")) return } @@ -59,7 +59,7 @@ func main() { log.Fatal(err) } - log.Printf("nsqlookupd v%s", util.BINARY_VERSION) + log.Println(util.Version("nsqlookupd")) lookupd = NewNSQLookupd() lookupd.tcpAddr = tcpAddr diff --git a/util/binary_version.go b/util/binary_version.go index 51bc5b8d4..af595c000 100644 --- a/util/binary_version.go +++ b/util/binary_version.go @@ -1,3 +1,12 @@ package util +import ( + "fmt" + "runtime" +) + const BINARY_VERSION = "0.2.20-alpha" + +func Version(app string) string { + return fmt.Sprintf("%s v%s (built w/%s)", app, BINARY_VERSION, runtime.Version()) +}