Ejemplo n.º 1
0
func worker(id int8) {
	db, err := dbase.ConnectFromEnv()
	if err != nil {
		log.Println("[+] lobsterdb connected to database (preparing select)")
	}
	defer db.Close()
	for {
		s := <-newStories
		err := s.process(db)
		if err != nil {
			log.Printf("[!] worker %d error processing story: %s",
				id, err)
		}
	}
}
Ejemplo n.º 2
0
func rootPage(w http.ResponseWriter, req *http.Request) {
	db, err := dbase.ConnectFromEnv()
	stats := ""
	page := ""

	if err == nil {
		stats += "stats\n=====\n"
		stats += "last tweet: " + bot.LastUpdate()
		stats += fmt.Sprintf("\nstories posted: %d\n", dbase.CountStories(db))
	} else {
		stats += "couldn't connect to database: " + err.Error()
	}

	page += stats
	fmt.Fprintln(w, page)
}