package daemon import ( "log" "github.com/go-flucky/flucky/pkg/config" "github.com/go-flucky/flucky/pkg/daemon" "github.com/spf13/cobra" "github.com/volker-raschek/go-logger/pkg/logger" ) var ( cachedMeasuredValues uint compression bool configFile *string round float64 temperatureUnit 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) } logger := logger.NewDefaultLogger(logger.LogLevelDebug) daemon.SetLogger(logger) daemon.Start(cnf, cachedMeasuredValues, compression, round) }, } func InitCmd(cmd *cobra.Command, cnfFile *string) { configFile = cnfFile cmd.AddCommand(daemonCmd) daemonCmd.Flags().BoolVar(&compression, "compression", true, "Compress measured values") daemonCmd.Flags().UintVar(&cachedMeasuredValues, "cached-values", 500, "Number of cached values before saveing into the storage endpoint") daemonCmd.Flags().Float64Var(&round, "round", 0.5, "Round values. The value 0 deactivates the function") }