mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Easy way to print version information, bumped version
This commit is contained in:
17
gnatsd.go
17
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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user