Ejemplo n.º 1
0
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)
}
Ejemplo n.º 2
0
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)
	}
}
Ejemplo n.º 3
0
func main() {
	logSetup := utils.NewDefaultLogSetup(serverLog)
	logSetup.SetupLogging()
	go utils.ListenForLogSignal(logSetup)

	router := mux.NewRouter()

	// add subway stuffs to server
	sconfig := NewConfig(subwayConfig)
	setupSubway(router, sconfig, subwayWeb, "subway.jprbnsn.com")
	setupSubway(router, sconfig, subwayWeb, "wheresthetrain.nyc")
	setupSubway(router, sconfig, subwayWeb, "www.wheresthetrain.nyc")
	setupSubway(router, sconfig, subwayWeb, "wtt.nyc")
	setupSubway(router, sconfig, subwayWeb, "www.wtt.nyc")
	setupSubway(router, sconfig, wheresLWeb, "wheresthel.com")
	setupSubway(router, sconfig, wheresLWeb, "www.wheresthel.com")

	// add subway stuffs to server
	// add the countdown
	countdownRouter := router.Host("countdown.jprbnsn.com").Subrouter()
	countdownRouter.PathPrefix("/").Handler(http.FileServer(http.Dir("/opt/jp/www/thecountdown")))

	// add wg4gl
	setupWG4GL(router, "wg4gl.com")
	setupWG4GL(router, "www.wg4gl.com")

	setupColin(router, "colinjhiggins.com")
	setupColin(router, "www.colinjhiggins.com")

	setupJP(router, "jprbnsn.com")
	setupJP(router, "www.jprbnsn.com")

	// newshound API setup
	nconfig := NewConfig(houndConfig)
	newshoundAPI := api.NewNewshoundAPI(nconfig.DBURL, nconfig.DBUser, nconfig.DBPassword)
	// add newshound subdomain to webserver
	newshoundRouter := router.Host("newshound.jprbnsn.com").Subrouter()
	// add newshound's API to the subdomain
	newshoundAPIRouter := newshoundRouter.PathPrefix(newshoundAPI.UrlPrefix()).Subrouter()
	newshoundAPI.Handle(newshoundAPIRouter)
	// add newshound UI to to the subdomain
	newshoundRouter.PathPrefix("/").Handler(http.FileServer(http.Dir(newshoundWeb)))

	// add newshound barkd websockets
	barkdRouter := router.Host("newshound.jprbnsn.com:8888").Subrouter()
	barkdURL, _ := url.Parse("http://127.0.0.1:8888")
	barkdRouter.PathPrefix("/").Handler(httputil.NewSingleHostReverseProxy(barkdURL))

	handler := web.AccessLogHandler(accessLog, router)

	log.Fatal(http.ListenAndServe(":80", handler))
}
Ejemplo n.º 4
0
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))
}