I have created an executable in GO and I am running it as a windows service.
I am using golang.org/x/sys/windows/svc package, and provide it with the Execute method which gets called by the SCM
run := svc.Run
_ = run(svcName, &myservice{})
func (m *myservice) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) {
changes <- svc.Status{State: svc.StartPending}
go mainmethod()
changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
}
The service works most of the time but the problem is that whenever I restart my system, the service gives me a Error 1053 : "The service did not respond to start or control request in a timely fashion" error and does not start,
After adding the log statements in my run and Execute methods, I figured out that when the service starts without error the logs get printed, but when the services gives a 1053 error the SCM does not even invoke my exe, since none of the log statements get printed. Has anyone tried creating a windows service in a similar way? Is it a problem with implementation or the windows svc package?
Thanks