diff --git a/.travis.yml b/.travis.yml index 39982154..bcbbd4c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: go go: +- 1.13.x - 1.12.x addons: apt: diff --git a/main.go b/main.go index 4d976622..9b8d1483 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ import ( "flag" "fmt" "os" + "runtime" "github.com/nats-io/nats-server/v2/server" ) @@ -109,4 +110,5 @@ func main() { if err := server.Run(s); err != nil { server.PrintAndDie(err.Error()) } + runtime.Goexit() } diff --git a/server/server.go b/server/server.go index 1184428f..43b40341 100644 --- a/server/server.go +++ b/server/server.go @@ -1168,7 +1168,7 @@ func (s *Server) Shutdown() { s.mu.Unlock() return } - s.Noticef("Server Exiting..") + s.Noticef("Initiating Shutdown...") opts := s.getOpts() @@ -1271,6 +1271,7 @@ func (s *Server) Shutdown() { s.deletePortsFile(opts.PortsFileDir) } + s.Noticef("Server Exiting..") // Close logger if applicable. It allows tests on Windows // to be able to do proper cleanup (delete log file). s.logging.RLock() diff --git a/server/service_windows.go b/server/service_windows.go index 56450413..d24f6414 100644 --- a/server/service_windows.go +++ b/server/service_windows.go @@ -18,7 +18,6 @@ import ( "time" "golang.org/x/sys/windows/svc" - "golang.org/x/sys/windows/svc/debug" ) const ( @@ -110,15 +109,15 @@ func Run(server *Server) error { server.Start() return nil } - run := svc.Run isInteractive, err := svc.IsAnInteractiveSession() if err != nil { return err } if isInteractive { - run = debug.Run + server.Start() + return nil } - return run(serviceName, &winServiceWrapper{server}) + return svc.Run(serviceName, &winServiceWrapper{server}) } // isWindowsService indicates if NATS is running as a Windows service. diff --git a/server/signal.go b/server/signal.go index a6533044..254e3ecb 100644 --- a/server/signal.go +++ b/server/signal.go @@ -49,7 +49,7 @@ func (s *Server) handleSignals() { s.Debugf("Trapped %q signal", sig) switch sig { case syscall.SIGINT: - s.Noticef("Server Exiting..") + s.Shutdown() os.Exit(0) case syscall.SIGUSR1: // File log re-open for rotating file logs. diff --git a/server/signal_windows.go b/server/signal_windows.go index b940202f..a3667c80 100644 --- a/server/signal_windows.go +++ b/server/signal_windows.go @@ -35,7 +35,7 @@ func (s *Server) handleSignals() { go func() { for sig := range c { s.Debugf("Trapped %q signal", sig) - s.Noticef("Server Exiting..") + s.Shutdown() os.Exit(0) } }() diff --git a/test/configs/authorization.conf b/test/configs/authorization.conf index 69d62299..e6964679 100644 --- a/test/configs/authorization.conf +++ b/test/configs/authorization.conf @@ -5,7 +5,7 @@ authorization { include "auths.conf" # Just foo for testing - PASS: $2a$10$UHR6GhotWhpLsKtVP0/i6.Nh9.fuY73cWjLoJjb2sKT8KISBcUW5q + PASS: $2a$04$P/.bd.7unw9Ew7yWJqXsl.f4oNRLQGvadEL2YnqQXbbb.IVQajRdK # Users listed with permissions. users = [ diff --git a/vendor/golang.org/x/sys/windows/svc/debug/log.go b/vendor/golang.org/x/sys/windows/svc/debug/log.go deleted file mode 100644 index e51ab42a..00000000 --- a/vendor/golang.org/x/sys/windows/svc/debug/log.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package debug - -import ( - "os" - "strconv" -) - -// Log interface allows different log implementations to be used. -type Log interface { - Close() error - Info(eid uint32, msg string) error - Warning(eid uint32, msg string) error - Error(eid uint32, msg string) error -} - -// ConsoleLog provides access to the console. -type ConsoleLog struct { - Name string -} - -// New creates new ConsoleLog. -func New(source string) *ConsoleLog { - return &ConsoleLog{Name: source} -} - -// Close closes console log l. -func (l *ConsoleLog) Close() error { - return nil -} - -func (l *ConsoleLog) report(kind string, eid uint32, msg string) error { - s := l.Name + "." + kind + "(" + strconv.Itoa(int(eid)) + "): " + msg + "\n" - _, err := os.Stdout.Write([]byte(s)) - return err -} - -// Info writes an information event msg with event id eid to the console l. -func (l *ConsoleLog) Info(eid uint32, msg string) error { - return l.report("info", eid, msg) -} - -// Warning writes an warning event msg with event id eid to the console l. -func (l *ConsoleLog) Warning(eid uint32, msg string) error { - return l.report("warn", eid, msg) -} - -// Error writes an error event msg with event id eid to the console l. -func (l *ConsoleLog) Error(eid uint32, msg string) error { - return l.report("error", eid, msg) -} diff --git a/vendor/golang.org/x/sys/windows/svc/debug/service.go b/vendor/golang.org/x/sys/windows/svc/debug/service.go deleted file mode 100644 index e621b87a..00000000 --- a/vendor/golang.org/x/sys/windows/svc/debug/service.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -// Package debug provides facilities to execute svc.Handler on console. -// -package debug - -import ( - "os" - "os/signal" - "syscall" - - "golang.org/x/sys/windows/svc" -) - -// Run executes service name by calling appropriate handler function. -// The process is running on console, unlike real service. Use Ctrl+C to -// send "Stop" command to your service. -func Run(name string, handler svc.Handler) error { - cmds := make(chan svc.ChangeRequest) - changes := make(chan svc.Status) - - sig := make(chan os.Signal) - signal.Notify(sig) - - go func() { - status := svc.Status{State: svc.Stopped} - for { - select { - case <-sig: - cmds <- svc.ChangeRequest{Cmd: svc.Stop, CurrentStatus: status} - case status = <-changes: - } - } - }() - - _, errno := handler.Execute([]string{name}, cmds, changes) - if errno != 0 { - return syscall.Errno(errno) - } - return nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 058c0672..6730441a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -16,7 +16,6 @@ golang.org/x/crypto/ed25519/internal/edwards25519 # golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e golang.org/x/sys/windows/svc/eventlog golang.org/x/sys/windows/svc -golang.org/x/sys/windows/svc/debug golang.org/x/sys/windows/svc/mgr golang.org/x/sys/windows golang.org/x/sys/windows/registry