spindles
spindles

Reputation: 137

Golang: HTTP deployment under Windows

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?

Upvotes: 12

Views: 7479

Answers (2)

Benjamin BALET
Benjamin BALET

Reputation: 969

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

Upvotes: 14

Afriza N. Arief
Afriza N. Arief

Reputation: 7876

  1. Use NSSM (create service from any executable)

nssm install MyService d:\MyService.exe

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

... others ...

Upvotes: 1

Related Questions