Easy way to print version information, bumped version

This commit is contained in:
Derek Collison
2013-06-08 12:52:40 -07:00
parent b703e6583d
commit c4f34906fc
3 changed files with 25 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import (
"log"
"net/http"
_ "net/http/pprof"
"strings"
"github.com/apcera/gnatsd/server"
)
@@ -17,6 +18,7 @@ func main() {
opts := server.Options{}
var showVersion bool
var debugAndTrace bool
var configFile string
@@ -38,13 +40,28 @@ func main() {
flag.IntVar(&opts.HttpPort, "http_port", 0, "HTTP Port for /varz, /connz endpoints.")
flag.StringVar(&configFile, "c", "", "Configuration file.")
flag.StringVar(&configFile, "config", "", "Configuration file.")
flag.BoolVar(&showVersion, "version", false, "Print version information.")
flag.BoolVar(&showVersion, "v", false, "Print version information.")
flag.Parse()
// Show version and exit
if showVersion {
server.PrintServerAndExit()
}
if debugAndTrace {
opts.Trace, opts.Debug = true, true
}
// Process args, version only for now
for _, arg := range flag.Args() {
arg = strings.ToLower(arg)
if arg == "version" {
server.PrintServerAndExit()
}
}
var fileOpts *server.Options
var err error

View File

@@ -1,4 +1,4 @@
// Copyright 2012 Apcera Inc. All rights reserved.
// Copyright 2012,2013 Apcera Inc. All rights reserved.
package server
@@ -7,7 +7,7 @@ import (
)
const (
VERSION = "go-0.2.8.alpha.2"
VERSION = "go-0.2.10.alpha.1"
DEFAULT_PORT = 4222
DEFAULT_HOST = "0.0.0.0"

View File

@@ -94,6 +94,12 @@ func New(opts *Options) *Server {
return s
}
// Print our version and exit
func PrintServerAndExit() {
fmt.Printf("%s\n", VERSION)
os.Exit(0)
}
// Signal Handling
func (s *Server) handleSignals() {
if s.opts.NoSigs {