func main() { flag.Parse() if *logArg != "stderr" { logSetup := utils.NewDefaultLogSetup(*logArg) logSetup.SetupLogging() go utils.ListenForLogSignal(logSetup) } else { log.SetFlags(log.LstdFlags | log.Lshortfile) } config := newshound.NewConfig() sess, err := config.MgoSession() if err != nil { log.Fatal(err) } defer sess.Close() if *reparse { if err := fetch.ReParse(config, sess); err != nil { log.Fatal(err) } return } go fetchMail(config, sess) mapReduce(sess) }
func main() { flag.Parse() if *logArg != "stderr" { logSetup := utils.NewDefaultLogSetup(*logArg) logSetup.SetupLogging() go utils.ListenForLogSignal(logSetup) } else { log.SetFlags(log.LstdFlags | log.Lshortfile) } config := newshound.NewConfig() d, err := bark.NewDistributor(config.NSQDAddr, config.NSQLAddr, config.BarkdChannel) if err != nil { log.Fatal(err) } // SLACK for _, slackAlert := range config.SlackAlerts { bark.AddSlackAlertBot(d, slackAlert.Key, slackAlert.Bot) } for _, slackEvent := range config.SlackEvents { bark.AddSlackEventBot(d, slackEvent.Key, slackEvent.Bot) } // TWITTER for _, twitterCreds := range config.Twitter { anaconda.SetConsumerKey(twitterCreds.ConsumerKey) anaconda.SetConsumerSecret(twitterCreds.ConsumerSecret) bark.AddTwitterAlertBot(d, twitterCreds.AccessToken, twitterCreds.AccessTokenSecret) bark.AddTwitterEventBot(d, twitterCreds.AccessToken, twitterCreds.AccessTokenSecret) bark.AddTwitterEventUpdateBot(d, twitterCreds.AccessToken, twitterCreds.AccessTokenSecret) } // WEBSOCKETS if config.WSPort != 0 { bark.AddWebSocketBarker(d, config.WSPort, true, true) } // WOOF quit := d.ListenAndBark() // wait for kill ch := make(chan os.Signal, 1) signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL) log.Printf("Received signal %s. Initiating stop.", <-ch) // signal stop and wait errs := make(chan error, 1) quit <- errs err = <-errs if err != nil { log.Fatal("shut down error: ", err) } }
func main() { config := newshound.NewConfig() logSetup := utils.NewDefaultLogSetup(newshound.ServerLog) logSetup.SetupLogging() go utils.ListenForLogSignal(logSetup) router := mux.NewRouter() api := api.NewNewshoundAPI(config.DBURL, config.DBUser, config.DBPassword) apiRouter := router.PathPrefix(api.UrlPrefix()).Subrouter() api.Handle(apiRouter) staticRouter := router.PathPrefix("/").Subrouter() staticRouter.PathPrefix("/").Handler(http.FileServer(http.Dir(newshound.WebDir))) handler := web.AccessLogHandler(newshound.AccessLog, router) log.Fatal(http.ListenAndServe(":8080", handler)) }