Пример #1
0
func main() {

	// Register the first service
	floatSvc := new(math.FloatService)
	floatSvc.SvcObj = new(impl.FloatServiceImpl)
	babel.Register(floatSvc)

	// Register the second service
	fractSvc := new(math.FractionService)
	fractSvc.SvcObj = new(impl.FractionServiceImpl)
	babel.Register(fractSvc)

	// Set some info for the monitoring page
	kubismus.Setup("Math Service", "")
	kubismus.Note("Babel base path", "http://localhost:9999"+babel.DefaultHttpPath)
	kubismus.Note("Monitoring path", "http://localhost:9999"+kubismus.DefaultPath)
	kubismus.Note("Test harness path", "http://localhost:9999/test/")
	kubismus.Define("Requests", kubismus.COUNT, "Requests/sec")

	// Set up Babel HTTP handlers and serve HTTP
	http.Handle(babel.DefaultHttpPath, kubismus.HttpRequestMetric("Requests", babel.DefaultServer))
	kubismus.HandleHTTP()
	http.HandleFunc("/test/", harness.ServeHTTP)
	http.HandleFunc("/", frame)
	log.Fatal(http.ListenAndServe(":9999", nil))
}
Пример #2
0
func main() {
	// Parse flags from command-line
	flag.Parse()

	// Parser flags from config
	flagcfg.AddDefaults()
	flagcfg.Parse()

	// Parse flags from environment (using github.com/facebookgo/flagenv)
	flagenv.Prefix = "WEBNULL_"
	flagenv.Parse()

	if help {
		showHelp()
		return
	}

	// setup number of CPUs
	runtime.GOMAXPROCS(cpus)

	name, _ := os.Hostname()

	http.Handle("/status/", http.StripPrefix("/status", http.HandlerFunc(kubismus.ServeHTTP)))
	http.Handle("/", kubismus.HttpRequestMetric("Requests", handleRequest()))
	http.HandleFunc("/media/", ServeHTTP)

	kubismus.Setup("/web/null", "/media/null.png")
	kubismus.Note("Host Name", name)
	kubismus.Note("CPUs", fmt.Sprintf("%d of %d", runtime.GOMAXPROCS(0), runtime.NumCPU()))
	kubismus.Define("Requests", kubismus.COUNT, "Requests/second")
	kubismus.Define("Requests", kubismus.SUM, "Bytes/second")

	go calcMetrics()

	log.Fatal(http.ListenAndServe(addr, nil))
}