0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-21 21:49:51 +01:00
posthog/livestream/configs.go
2024-08-06 15:08:34 -07: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: %v", 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
}