2017-08-16 12:33 阅读 48

Windows Service无法启动GO Lang exe

I have created an executable in GO and I am running it as a windows service.

I am using 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?


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dongqu9972 dongqu9972 2017-08-23 10:59

    I have the GO exe deployed in Program Files, I changed the LogOnAs attribute of Windows Service to "Local Service" and gave "Local Service" complete Access to the installation folder in "Folder Security".

    This seems to fix the issue for windows10. The service starts on windows restart, But this fix still does not work for windows 7 and windows8.


    Making the service "Automatic Delayed" works, however you have to wait for the service start after boot which takes 2-3 minutes.

    The answer mentioned here helped:

    点赞 评论 复制链接分享