You need to create a service, put it into autoload and communicate with it. How to make ordinary applications-understandable, but how to make the same application a service?
thank
- A live example: GoGS tutorial . - D-side
- godoc.org/golang.org/x/sys/windows/svc - Ivan Black 8:54 pm
1 answer
I offer 2 options:
You write the usual go program, which is spinning in an infinite loop and does what is necessary (listens to ports / signals / files and so you communicate with it). Then, using the nssm program, you install it as a service MyService:
nssm install MyService d:\MyService.exeand manage it from a service or the same nssm.Without third-party programs. There is a package of svc from add-ons. With it, you can create a program that integrates into the service of services and understands all the commands from this service, and you yourself determine the behavior of the transferred commands (pause, continuation), which you can not do in case 1. There's even an example of such a simple example service. You can take it as a basis and change the main method to your needs.