12

The Go language provides handlers for serving HTTP responses. It is easy enough to start up a Go program on the command prompt, that listens for incoming HTTP requests.

What are the deployment options for running such a Go program in the background on a Windows Server machine? For example, is there a standard method for creating a Windows Service that runs the Go program in the background?

3
  • 3
    Can you not just create a service and set its target to the Go executable? Commented Jun 23, 2014 at 3:08
  • 3
    possible duplicate of Create Windows service from executable Commented Jun 23, 2014 at 6:59
  • @SimonWhitehead, thanks for the tip. I'll try to create a service using the Sv.exe command to run the Go program Commented Jun 23, 2014 at 13:35

2 Answers 2

14

There is an excellent golang package kardianos/service that will allow you to create a service whatever the platform you are targeting.

As you can see here (it is in french but what is interesting is the code sample at the begginning of the page), it is easy to extend your program with command line options such as :

  • install install the service.
  • remove remove the service.
  • run simply run the program (not as a service).
  • start/stop the service
Sign up to request clarification or add additional context in comments.

1 Comment

@EthanMick I fixed the link to an archive : decouvric.cluster013.ovh.net/golang/thirdparty/divers/…
1
  1. Use NSSM (create service from any executable)

nssm install MyService d:\MyService.exe

  1. Use golang.org/x/sys/windows/svc package

... others ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.