PKGBUILD/main.go
Markus Pesch fb8d4dd5eb
fix: new implementation
changes:
- Remove cli
  Some cli commands are not complete tested and are deprecated.

- Daemon
  - Old version has a very bad implementation of how to verify, if the
    device or the sensors are in the database insert. The current
    implementation can be improved but this one is betten then the old
    one.
  - Remove complete the cache store implementation. Use a normal array
    and query the length and capacity to determine how the array cache
    must be cleaned.

- Type
  Remove unused types and functions
2020-05-03 14:09:22 +02:00

93 lines
2.3 KiB
Go

package main
import (
"log"
"strings"
"github.com/volker-raschek/flucky/pkg/config"
"github.com/volker-raschek/flucky/pkg/daemon"
"github.com/volker-raschek/go-logger/pkg/logger"
)
var (
version string
)
func main() {
// sversion, err := semver.NewVersion(version)
// if err != nil {
// log.Printf("The sematic versioning is invalid: %v", version)
// os.Exit(1)
// }
cnfString := `{
"device": {
"id": "d0c600bc-6eab-4b9b-b93f-dc0477b4658f",
"name": "poseidon",
"location": null,
"last_contact": null,
"creation_date": "2020-04-23T22:09:20.932+02:00"
},
"storage_endpoint": "postgres://postgres:postgres@markus-pc.trier.cryptic.systems:5432/postgres?sslmode=disable",
"sensors": [
{
"id": "1c180121-9e98-4053-a6f6-4ed7fad3935b",
"name": "bme280",
"location": "",
"wire_id": null,
"i2c_bus": 1,
"i2c_address": 118,
"gpio_number": null,
"model": "BME280",
"enabled": true,
"last_contact": null,
"tick_duration": "5s",
"device_id": "d0c600bc-6eab-4b9b-b93f-dc0477b4658f",
"creation_date": "2020-04-23T22:09:20.934+02:00"
},
{
"id": "5cebd127-8976-4b66-b1bb-e551f26c4af4",
"name": "ds18b20_2",
"location": "",
"wire_id": "28-02131dbffeaa",
"i2c_bus": null,
"i2c_address": null,
"gpio_number": null,
"model": "DS18B20",
"enabled": true,
"last_contact": null,
"tick_duration": "1m",
"device_id": "d0c600bc-6eab-4b9b-b93f-dc0477b4658f",
"creation_date": "2020-04-23T22:09:27.901+02:00"
},
{
"id": "579628cc-b667-4b56-b305-73256c0c9dce",
"name": "ds18b20",
"location": "",
"wire_id": "28-01131646f11d",
"i2c_bus": null,
"i2c_address": null,
"gpio_number": null,
"model": "DS18B20",
"enabled": true,
"last_contact": null,
"tick_duration": "1m",
"device_id": "d0c600bc-6eab-4b9b-b93f-dc0477b4658f",
"creation_date": "2020-04-23T22:09:56.468+02:00"
}
]
}`
cnf, err := config.Decode(strings.NewReader(cnfString))
if err != nil {
log.Fatal(err)
}
flogger := logger.NewDefaultLogger(logger.LogLevelDebug)
err = daemon.Start(cnf, flogger)
if err != nil {
log.Fatal(err)
}
}