feat(daemon): new flag to set compression
This commit is contained in:
parent
17e5cef737
commit
3d07cbc9ba
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var compression bool
|
||||||
var configPath string
|
var configPath string
|
||||||
|
|
||||||
var daemonCmd = &cobra.Command{
|
var daemonCmd = &cobra.Command{
|
||||||
@ -20,7 +21,7 @@ var daemonCmd = &cobra.Command{
|
|||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = daemon.Start(cnf)
|
err = daemon.Start(cnf, compression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -30,7 +31,7 @@ var daemonCmd = &cobra.Command{
|
|||||||
|
|
||||||
func InitCmd(cmd *cobra.Command, cnfPath string) {
|
func InitCmd(cmd *cobra.Command, cnfPath string) {
|
||||||
configPath = cnfPath
|
configPath = cnfPath
|
||||||
|
|
||||||
cmd.AddCommand(daemonCmd)
|
cmd.AddCommand(daemonCmd)
|
||||||
|
daemonCmd.Flags().BoolVarP(&compression, "compression", "c", true, "Compress measured values")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Start the daemon
|
// Start the daemon
|
||||||
func Start(cnf *config.Configuration) error {
|
func Start(cnf *config.Configuration, compression bool) error {
|
||||||
|
|
||||||
interrupt := make(chan os.Signal, 1)
|
interrupt := make(chan os.Signal, 1)
|
||||||
signal.Notify(interrupt, os.Interrupt, os.Kill, syscall.SIGTERM)
|
signal.Notify(interrupt, os.Interrupt, os.Kill, syscall.SIGTERM)
|
||||||
@ -37,7 +37,7 @@ func Start(cnf *config.Configuration) error {
|
|||||||
log.Printf("Write measured values into logfile")
|
log.Printf("Write measured values into logfile")
|
||||||
|
|
||||||
log.Printf("%v new measured temperature values", len(temperatures))
|
log.Printf("%v new measured temperature values", len(temperatures))
|
||||||
err := logfile.WriteTemperatures(temperatures, cnf.Device.TemperatureLogfile, true)
|
err := logfile.WriteTemperatures(temperatures, cnf.Device.TemperatureLogfile, compression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Can not save temperatures: %v", err)
|
return fmt.Errorf("Can not save temperatures: %v", err)
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ func Start(cnf *config.Configuration) error {
|
|||||||
temperatures = append(temperatures, temperature)
|
temperatures = append(temperatures, temperature)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Temperature Channel closed. Write remaining values into the logfile")
|
log.Printf("Temperature Channel closed. Write remaining values into the logfile")
|
||||||
err := logfile.WriteTemperatures(temperatures, cnf.Device.TemperatureLogfile, true)
|
err := logfile.WriteTemperatures(temperatures, cnf.Device.TemperatureLogfile, compression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Can not save temperatures: %v", err)
|
return fmt.Errorf("Can not save temperatures: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user