Skip to content

Commit

Permalink
Rename pbs_light.go To main.go (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxNode authored Oct 16, 2019
1 parent addd3ae commit 5db4686
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions pbs_light.go → main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,37 @@ func init() {
func main() {
flag.Parse() // required for glog flags and testing package flags

v := viper.New()
config.SetupViper(v, "pbs")
cfg, err := config.New(v)
cfg, err := loadConfig()
if err != nil {
glog.Fatalf("Configuration could not be loaded or did not pass validation: %v", err)
}
if err := serve(Rev, cfg); err != nil {

err = serve(Rev, cfg)
if err != nil {
glog.Errorf("prebid-server failed: %v", err)
}
}

func loadConfig() (*config.Configuration, error) {
v := viper.New()
config.SetupViper(v, "pbs") // filke = filename
return config.New(v)
}

func serve(revision string, cfg *config.Configuration) error {
currencyConverter := currencies.NewRateConverter(&http.Client{}, cfg.CurrencyConverter.FetchURL, time.Duration(cfg.CurrencyConverter.FetchIntervalSeconds)*time.Second)
fetchingInterval := time.Duration(cfg.CurrencyConverter.FetchIntervalSeconds) * time.Second
currencyConverter := currencies.NewRateConverter(&http.Client{}, cfg.CurrencyConverter.FetchURL, fetchingInterval)

r, err := router.New(cfg, currencyConverter)
if err != nil {
return err
}
// Init prebid cache

pbc.InitPrebidCache(cfg.CacheURL.GetBaseURL())
// Add cors support

corsRouter := router.SupportCORS(r)
server.Listen(cfg, router.NoCache{Handler: corsRouter}, router.Admin(revision, currencyConverter), r.MetricsEngine)

r.Shutdown()
return nil
}
File renamed without changes.

0 comments on commit 5db4686

Please sign in to comment.