Use custom config type
This commit is contained in:
17
main.go
17
main.go
@@ -12,15 +12,26 @@ import (
|
||||
"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 = app.MustSetupConfigAndLogging(ctx)
|
||||
aw := ambient.New(ctx).Init()
|
||||
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{
|
||||
@@ -43,7 +54,7 @@ func main() {
|
||||
},
|
||||
}
|
||||
|
||||
// Run and wait
|
||||
awApp.MustRun()
|
||||
|
||||
<-awApp.Done()
|
||||
}
|
||||
|
Reference in New Issue
Block a user