PKGBUILD/cmd/daemon/daemon.go

37 lines
615 B
Go

package daemon
import (
"log"
"github.com/spf13/cobra"
"github.com/volker-raschek/flucky/pkg/config"
"github.com/volker-raschek/flucky/pkg/daemon"
)
var configPath string
var daemonCmd = &cobra.Command{
Use: "daemon",
Short: "Read continuously data from all enabled sensors",
Run: func(cmd *cobra.Command, args []string) {
// read configuration
cnf, err := config.Read(configPath)
if err != nil {
log.Fatalln(err)
}
err = daemon.Start(cnf)
if err != nil {
panic(err)
}
},
}
func InitCmd(cmd *cobra.Command, cnfPath string) {
configPath = cnfPath
cmd.AddCommand(daemonCmd)
}