diff --git a/Dockerfile.win64 b/Dockerfile.win64 new file mode 100644 index 00000000..848db66a --- /dev/null +++ b/Dockerfile.win64 @@ -0,0 +1,11 @@ +FROM golang:1.7.6 + +MAINTAINER Ivan Kozlovic + +COPY . /go/src/github.com/nats-io/gnatsd +WORKDIR /go/src/github.com/nats-io/gnatsd + +RUN CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o gnatsd.exe . + +ENTRYPOINT ["go"] +CMD ["version"] diff --git a/logger/syslog_windows.go b/logger/syslog_windows.go index 10eddc6b..f1d5644f 100644 --- a/logger/syslog_windows.go +++ b/logger/syslog_windows.go @@ -5,9 +5,10 @@ package logger import ( "fmt" - "golang.org/x/sys/windows/svc/eventlog" "os" "strings" + + "golang.org/x/sys/windows/svc/eventlog" ) const ( diff --git a/logger/syslog_windows_test.go b/logger/syslog_windows_test.go index c14c7b56..3c6b2a76 100755 --- a/logger/syslog_windows_test.go +++ b/logger/syslog_windows_test.go @@ -4,10 +4,11 @@ package logger import ( - "golang.org/x/sys/windows/svc/eventlog" "os/exec" "strings" "testing" + + "golang.org/x/sys/windows/svc/eventlog" ) // Skips testing if we do not have privledges to run this test. diff --git a/server/const.go b/server/const.go index 29a9214c..93636224 100644 --- a/server/const.go +++ b/server/const.go @@ -19,7 +19,7 @@ const ( const ( // VERSION is the current version for the server. - VERSION = "1.0.0" + VERSION = "1.0.1" // DEFAULT_PORT is the default port for client connections. DEFAULT_PORT = 4222 diff --git a/server/service_windows.go b/server/service_windows.go index aa840fe3..d9b3ea70 100644 --- a/server/service_windows.go +++ b/server/service_windows.go @@ -3,6 +3,7 @@ package server import ( + "os" "time" "golang.org/x/sys/windows/svc" @@ -22,6 +23,14 @@ type winServiceWrapper struct { server *Server } +var dockerized = false + +func init() { + if v, exists := os.LookupEnv("NATS_DOCKERIZED"); exists && v == "1" { + dockerized = true + } +} + // Execute will be called by the package code at the start of // the service, and the service will exit once Execute completes. // Inside Execute you must read service change requests from r and @@ -76,6 +85,10 @@ loop: // Run starts the NATS server as a Windows service. func Run(server *Server) error { + if dockerized { + server.Start() + return nil + } run := svc.Run isInteractive, err := svc.IsAnInteractiveSession() if err != nil { @@ -89,6 +102,9 @@ func Run(server *Server) error { // isWindowsService indicates if NATS is running as a Windows service. func isWindowsService() bool { + if dockerized { + return false + } isInteractive, _ := svc.IsAnInteractiveSession() return !isInteractive }