package main import ( "git.timovolkmann.de/gyrogpsc/core" "git.timovolkmann.de/gyrogpsc/storage" "git.timovolkmann.de/gyrogpsc/web" "github.com/sirupsen/logrus" "github.com/spf13/viper" "net/http" _ "net/http/pprof" ) func main() { go func() { logrus.Println(http.ListenAndServe("localhost:6060", nil)) }() conf := configurationFromFile() logrus.Debug(conf) repo := storage.NewRepository(conf) disp := core.NewDispatcher() service := core.TrackingService(conf, repo, disp) web.CreateServer(service, disp, conf) } func configurationFromFile() *core.Configuration { viper.SetDefault("collectors.porttcp", ":3010") viper.SetDefault("collectors.portserial", "/dev/tty.usbmodem14201") viper.SetDefault("webserver.port", ":3011") viper.SetDefault("pipeline.publishIntervalMs", 50) viper.SetDefault("pipeline.syncUpdateIntervalMs", 494) viper.SetDefault("debuglevel", "INFO") viper.SetConfigName("gpsconfig") // name of config file (without extension) viper.SetConfigType("yaml") viper.AddConfigPath(".") viper.AddConfigPath("./../../") if err := viper.ReadInConfig(); err != nil { logrus.Warn("couldn't find config file. using standard configuration") } c := core.Configuration{} if err := viper.Unmarshal(&c); err != nil { logrus.Debug("couldn't load config...") logrus.Error(err) } lvl, err := logrus.ParseLevel(c.Debuglevel) if err != nil { logrus.Error(err) } logrus.SetLevel(lvl) return &c }