A simple Windows service that, every 2 or 5 seconds, sends a message to a MQTT broker.
-
Build the application for Windows:
make build
-
Register the service (as administrator):
sc.exe create golang-winservice ` displayname= "Golang Sample Windows Service" ` binPath= "$((Get-Location).Path)\golang-winservice.exe" sc.exe description golang-winservice ` "Simple windows service sending messages to a MQTT broker."
-
Create the
C:\ProgramData\golang-winservice\config.yml
configuration file:mqtt: broker: tcp://localhost:1883 topic: test/topic intervals: fast: 2 slow: 5
-
Use the Windows Service Control Manager to start the service.
-
Deregister the service (as administrator):
sc.exe delete golang-winservice