package main import ( "context" "os" "os/signal" "gitea.libretechconsulting.com/rmcguire/go-app/pkg/app" "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv" "golang.org/x/sys/unix" "gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/ambient" ) const defaultMetricPrefix = "weather" func main() { ctx, cncl := signal.NotifyContext(context.Background(), os.Kill, unix.SIGTERM) defer cncl() // Config type for app, which implements go-app/config.AppConfig awConfig := &ambient.AmbientLocalExporterConfig{ MetricPrefix: defaultMetricPrefix, WeatherStations: make([]ambient.WeatherStation, 0), } // Read config and environment, set up logging, load up // an appCtx, and prepare ambient weather local exporter ctx, awConfig = app.MustLoadConfigInto(ctx, awConfig) // Prepare the exporter aw := ambient.New(ctx, awConfig).Init() // Define and prepare the app awApp := app.App{ AppContext: ctx, HTTP: &app.AppHTTP{ Funcs: []srv.HTTPFunc{ { Path: "/weatherstation/updateweatherstation.php", HandlerFunc: aw.GetWundergroundHandlerFunc(ctx), }, { Path: "/data/report", HandlerFunc: aw.GetAWNHandlerFunc(ctx), }, }, HealthChecks: []srv.HealthCheckFunc{ // TODO: Implement func(ctx context.Context) error { return nil }, }, }, } // Run and wait awApp.MustRun() <-awApp.Done() }