Skip to content

vbossica/golang-winservice

Repository files navigation

Go Windows Service

A simple Windows service that, every 2 or 5 seconds, sends a message to a MQTT broker.

Building and Running

  1. Build the application for Windows:

    make build
  2. 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."
  3. Create the C:\ProgramData\golang-winservice\config.yml configuration file:

    mqtt:
      broker: tcp://localhost:1883
      topic: test/topic
    
    intervals:
      fast: 2
      slow: 5
  4. Use the Windows Service Control Manager to start the service.

    Services registry
  5. Deregister the service (as administrator):

    sc.exe delete golang-winservice

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published