feat(daemon): add new subcommand to start a daemon
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/volker-raschek/flucky/cmd/daemon"
|
||||
"github.com/volker-raschek/flucky/cmd/sensor"
|
||||
"github.com/volker-raschek/flucky/cmd/temperature"
|
||||
"github.com/volker-raschek/flucky/pkg/types"
|
||||
@ -53,7 +54,7 @@ func Execute(version string) {
|
||||
rootCmd.Version = version
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&configPath, "config", "/etc/flucky/config.json", "Config file")
|
||||
// humidity.InitCmd(rootCmd, configPath)
|
||||
daemon.InitCmd(rootCmd, configPath)
|
||||
sensor.InitCmd(rootCmd, configPath)
|
||||
temperature.InitCmd(rootCmd, configPath)
|
||||
rootCmd.Execute()
|
||||
|
@ -1,7 +1,11 @@
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/volker-raschek/flucky/pkg/config"
|
||||
"github.com/volker-raschek/flucky/pkg/daemon"
|
||||
)
|
||||
|
||||
var configPath string
|
||||
@ -11,10 +15,15 @@ var daemonCmd = &cobra.Command{
|
||||
Short: "Read continuously data from all enabled sensors",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// read configuration
|
||||
// cnf, err := config.Read(configPath)
|
||||
// if err != nil {
|
||||
// log.Fatalln(err)
|
||||
// }
|
||||
cnf, err := config.Read(configPath)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
err = daemon.Start(cnf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user