fix(pkg/sensor): use context to terminate go routines

This commit is contained in:
2019-06-17 23:37:48 +02:00
parent 502e3b3b1c
commit 2941f7a527
11 changed files with 298 additions and 80 deletions

View File

@ -14,6 +14,7 @@ import (
var compression bool
var logs bool
var round float64
var readTemperatureCmd = &cobra.Command{
Use: "read",
@ -35,8 +36,7 @@ var readTemperatureCmd = &cobra.Command{
temperatureSensors = cnf.GetTemperatureSensorsByName(args)
}
// read temperature from sensors
temperatures, err := sensor.ReadTemperatures(temperatureSensors)
temperatures, err := sensor.ReadTemperatures(temperatureSensors, round)
if err != nil {
log.Fatalln(err)
}
@ -55,6 +55,7 @@ var readTemperatureCmd = &cobra.Command{
func init() {
temperatureCmd.AddCommand(readTemperatureCmd)
readTemperatureCmd.Flags().BoolVarP(&logs, "logs", "l", true, "Log temperature")
readTemperatureCmd.Flags().BoolVarP(&compression, "compression", "c", true, "Compress measured with logged temperatures")
readTemperatureCmd.Flags().BoolVar(&logs, "logs", true, "Log temperature")
readTemperatureCmd.Flags().BoolVar(&compression, "compression", true, "Compress measured with logged temperatures")
readTemperatureCmd.Flags().Float64VarP(&round, "round", "r", 0.25, "Round values. The value 0 deactivates the function")
}