0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-29 03:04:16 +01:00
posthog/livestream/configs.go
James Greenhill 37f7c8ec9a
chore: add sentry to liveevents (#23057)
* chore: add sentry to liveevents

* Use `isProd` for `Debug`

* Add a bunch of `CaptureException` calls

* Properly bubble `getPGConn()` error

* Fix `ParseIP` error handling

* Remove unused `personFromDistinctId()`

---------

Co-authored-by: Michael Matloka <dev@twixes.com>
Co-authored-by: Michael Matloka <michal@matloka.com>
2024-06-19 21:23:55 +00:00

37 lines
848 B
Go

package main
import (
"fmt"
"log"
"strings"
"github.com/fsnotify/fsnotify"
"github.com/getsentry/sentry-go"
"github.com/spf13/viper"
)
func loadConfigs() {
viper.SetConfigName("configs")
viper.AddConfigPath("configs/")
viper.SetDefault("kafka.group_id", "livestream")
viper.SetDefault("prod", false)
err := viper.ReadInConfig()
if err != nil {
sentry.CaptureException(err)
log.Fatalf("fatal error config file: %w", err)
}
viper.OnConfigChange(func(e fsnotify.Event) {
fmt.Println("Config file changed:", e.Name)
})
viper.WatchConfig()
viper.SetEnvPrefix("livestream") // will be uppercased automatically
replacer := strings.NewReplacer(".", "_")
viper.SetEnvKeyReplacer(replacer)
viper.BindEnv("jwt.secret") // read from LIVESTREAM_JWT_SECRET
viper.BindEnv("postgres.url") // read from LIVESTREAM_POSTGRES_URL
}