mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-14 18:20:42 -07:00
Merge pull request #544 from nats-io/fix_win_docker
[FIXED] Windows Docker Images
This commit is contained in:
11
Dockerfile.win64
Normal file
11
Dockerfile.win64
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM golang:1.7.6
|
||||
|
||||
MAINTAINER Ivan Kozlovic <ivan.kozlovic@apcera.com>
|
||||
|
||||
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"]
|
||||
@@ -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 (
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user