PKGBUILD/cmd/daemon/daemon.go

37 lines
605 B
Go
Raw Normal View History

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