-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
What version of Go are you using (go version
)?
$ go version go version go1.14.14 windows/amd64
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\Administrator\AppData\Local\go-build set GOENV=C:\Users\Administrator\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\Administrator\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=c:\go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=c:\go\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\2\go-build198320826=/tmp/go-build -gno-record-gcc-switches
What did you do?
Tried creating windows service for windows console application that runs webservice. Followed example from https://github.com/golang/sys/tree/master/windows/svc/example
Based on above example I'm able to install windows service using go. But when I try to start it with start parameter it is not working in expected way. I used following configuration for created windows service,
serviceConfig := mgr.Config{
StartType: mgr.StartManual,
DisplayName: name,
Description: desc,
BinaryPathName: ExecutablePath,
ServiceStartName: UserName,
Password: Password,
}
s, err = m.CreateService(name, w.ExecutablePath, serviceConfig, "init")
if err != nil {
log.Errorf("Failed to create %s service due to %s", name, err)
return err
}
defer s.Close()
I assume command line argument(start parameter) Added properly in service (init command appears with executable path so...), refer below image.
I programmed like whenever init is executed with that application, log will be written in log file. If I run that manually logs are properly updated. But with this windows service it is not working properly. Likewise I want to create webservice start/stop through windows service.
In above image "start parameter" field is also empty. Whether this is correct way of doing it ? If not please share examples.
What did you expect to see?
windows service with Start parameter would work properly.
What did you see instead?
Windows service with start parameter is not working properly.