Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 600 Bytes

README.md

File metadata and controls

36 lines (28 loc) · 600 Bytes

GoDoc

import (
	"fmt"
  	"time"

	"github.com/JPZ13/daemon"
)

// plug in any function that takes no arguments
// and returns an error
func action() error {
	return nil
}

func main() {
	dae := daemon.New(daemon.Config{
		Action:   action,
		Interval: 2 * time.Minute,
	})

	errCh := dae.Start()
	go func() {
		for err := range errCh {
			fmt.Println("Handling error ", err)
		}
	}()

	time.Sleep(5 * time.Minute)

	dae.Stop()
}