Skip to content

Commit

Permalink
Merge pull request #192 from mreiferson/build_versioning_192
Browse files Browse the repository at this point in the history
go build flags and golang version output
  • Loading branch information
jehiah committed May 2, 2013
2 parents 0a8dafe + e3bec65 commit b582783
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PREFIX=/usr/local
DESTDIR=
GOFLAGS=
BINDIR=${PREFIX}/bin
DATADIR=${PREFIX}/share

Expand All @@ -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/%
Expand Down
2 changes: 1 addition & 1 deletion examples/nsq_to_http/nsq_to_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
5 changes: 4 additions & 1 deletion nsqadmin/nsqadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"flag"
"fmt"
"github.com/bitly/nsq/util"
"log"
"net"
Expand Down Expand Up @@ -33,8 +34,8 @@ func main() {

flag.Parse()

log.Printf("nsqadmin v%s", util.BINARY_VERSION)
if *showVersion {
fmt.Println(util.Version("nsqadmin"))
return
}

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion nsqd/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions nsqd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func main() {
}

if *showVersion {
fmt.Printf("nsqd v%s\n", util.BINARY_VERSION)
fmt.Println(util.Version("nsqd"))
return
}

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions nsqlookupd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {
}

if *showVersion {
fmt.Printf("nsqlookupd v%s\n", util.BINARY_VERSION)
fmt.Println(util.Version("nsqlookupd"))
return
}

Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions util/binary_version.go
Original file line number Diff line number Diff line change
@@ -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())
}

0 comments on commit b582783

Please sign in to comment.