fix: breaking changes
changes: - remove remote operations - add function to write measured values into a channel - add get humidity sensors from config - add get temperature sensors from config - remove FileLogger - exclude some functions from pkf into internal
This commit is contained in:
		
							
								
								
									
										33
									
								
								pkg/daemon/daemon.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								pkg/daemon/daemon.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| package daemon | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"os/signal" | ||||
| 	"syscall" | ||||
|  | ||||
| 	"github.com/volker-raschek/flucky/pkg/config" | ||||
| 	"github.com/volker-raschek/flucky/pkg/sensor" | ||||
| 	"github.com/volker-raschek/flucky/pkg/types" | ||||
| ) | ||||
|  | ||||
| // Start the daemon | ||||
| func Start(cnf *config.FluckyConfig) error { | ||||
|  | ||||
| 	interrupt := make(chan os.Signal, 1) | ||||
| 	signal.Notify(interrupt, os.Interrupt, os.Kill, syscall.SIGTERM) | ||||
|  | ||||
| 	humidityChannel := make(chan *types.Humidity) | ||||
| 	temperatureChannel := make(chan *types.Temperature) | ||||
|  | ||||
| 	go sensor.ReadHumiditiesContinuously(humiditySensors, humidityChannel) | ||||
| 	go sensor.ReadTemperaturesContinuously(temperatureSensors, temperatureChannel) | ||||
|  | ||||
| 	for { | ||||
| 		select { | ||||
| 		case killSignal := <-interrupt: | ||||
| 			return fmt.Errorf("Daemon was interruped by system signal %v", killSignal) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user