mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Handle run errors
This commit is contained in:
4
main.go
4
main.go
@@ -183,7 +183,9 @@ func main() {
|
||||
s.ConfigureLogger()
|
||||
|
||||
// Start things up. Block here until done.
|
||||
server.Run(s)
|
||||
if err := server.Run(s); err != nil {
|
||||
server.PrintAndDie(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func configureTLS(opts *server.Options) {
|
||||
|
||||
@@ -5,6 +5,7 @@ package server
|
||||
|
||||
// Run starts the NATS server. This wrapper function allows Windows to add a
|
||||
// hook for running NATS as a service.
|
||||
func Run(server *Server) {
|
||||
func Run(server *Server) error {
|
||||
server.Start()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/windows/svc"
|
||||
"golang.org/x/sys/windows/svc/debug"
|
||||
)
|
||||
|
||||
const serviceName = "gnatsd"
|
||||
@@ -65,6 +66,14 @@ loop:
|
||||
}
|
||||
|
||||
// Run starts the NATS server as a Windows service.
|
||||
func Run(server *Server) {
|
||||
svc.Run(serviceName, &winServiceWrapper{server})
|
||||
func Run(server *Server) error {
|
||||
run := svc.Run
|
||||
isInteractive, err := svc.IsAnInteractiveSession()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if isInteractive {
|
||||
run = debug.Run
|
||||
}
|
||||
return run(serviceName, &winServiceWrapper{server})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user