From e75675db7b382128f268e35ba8ea3300e11124ec Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Sat, 8 Jun 2013 12:52:40 -0700 Subject: [PATCH] Easy wat to print version, bumped version --- gnatsd.go | 17 +++++++++++++++++ server/const.go | 4 ++-- server/server.go | 6 ++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gnatsd.go b/gnatsd.go index 3a655666..50f6ea3a 100644 --- a/gnatsd.go +++ b/gnatsd.go @@ -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 diff --git a/server/const.go b/server/const.go index b579cc9d..1c65d46c 100644 --- a/server/const.go +++ b/server/const.go @@ -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" diff --git a/server/server.go b/server/server.go index ecc25989..921d590f 100644 --- a/server/server.go +++ b/server/server.go @@ -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 {