package daemon import ( "log" "time" "github.com/go-flucky/flucky/pkg/config" "github.com/go-flucky/flucky/pkg/daemon" "github.com/spf13/cobra" ) var compression bool var configFile string var cleanCacheIntervall 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(configFile) if err != nil { log.Fatalln(err) } duration, err := time.ParseDuration(cleanCacheIntervall) if err != nil { log.Fatalf("Can not parse clean cache interval into duration time: %v", err) } err = daemon.Start(cnf, duration, compression) if err != nil { log.Fatalln(err) } }, } func InitCmd(cmd *cobra.Command, cnfFile string) { configFile = cnfFile cmd.AddCommand(daemonCmd) daemonCmd.Flags().BoolVar(&compression, "compression", true, "Compress measured values") daemonCmd.Flags().StringVar(&cleanCacheIntervall, "clean-cache-intervall", "30m", "Minute intervall to clean cache and write measured values into logfile") }