Beispiel #1
0
func main() {
	flag.Parse()
	defer glog.Flush()

	router := mux.NewRouter()
	router.HandleFunc("/", indexHandler).Methods("GET")
	router.HandleFunc("/debug", debugHandler).Methods("GET", "POST")
	router.HandleFunc("/query", queryHandler).Methods("GET", "POST")
	router.HandleFunc("/ingest", ingestHandler).Methods("POST")

	router.HandleFunc("/stats", statsHandler).Methods("GET")
	router.HandleFunc("/purge", purgeHandler).Methods("GET")

	loggingHandler := NewLoggingHandler(router)
	serverAddr := fmt.Sprintf(":%d", 8080)
	server := &http.Server{
		Addr:    serverAddr,
		Handler: loggingHandler,
	}

	if err := echoprint.DBConnect(); err != nil {
		glog.Fatal(err)
	}
	defer echoprint.DBDisconnect()

	// TODO: gracefully stop http server (github.com/tylerb/graceful etc)
	glog.Infof("Starting server [%s]", serverAddr)
	if err := server.ListenAndServe(); err != nil {
		glog.Fatal(err)
	}
}
Beispiel #2
0
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s [options]\n", os.Args[0])
		flag.PrintDefaults()
		os.Exit(2)
	}

	flag.Parse()
	if *codegenPath == "" {
		flag.Usage()
	}

	codegenList, err := echoprint.ParseCodegenFile(*codegenPath)
	dieOrNah(err)

	err = echoprint.DBConnect()
	dieOrNah(err)
	defer echoprint.DBDisconnect()

	allMatches := echoprint.MatchAll(codegenList)

	for group, matches := range allMatches {
		log.Println("Matches for group ", group)
		for _, match := range matches {
			log.Printf("\t%+v", match)
		}
	}
}