Beispiel #1
0
func start(ctx *cli.Context) {
	if ctx.Bool("profile") {
		defer profile.Start(profile.CPUProfile).Stop()
		defer profile.Start(profile.MemProfile).Stop()
		defer profile.Start(profile.BlockProfile).Stop()
		defer profile.Start(profile.ProfilePath("."))
	}
	quit := make(chan bool)
	initLogrus(ctx)
	log.Info("Starting fullerite...")

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}
	handlers := createHandlers(c)
	hook := NewLogErrorHook(handlers)
	log.Logger.Hooks.Add(hook)

	startHandlers(handlers)
	collectors := startCollectors(c)

	collectorStatChan := make(chan metric.CollectorEmission)

	internalServer := internalserver.New(c,
		handlerStatFunc(handlers),
		readCollectorStat(collectorStatChan))

	go internalServer.Run()

	readFromCollectors(collectors, handlers, collectorStatChan)

	<-quit
}
Beispiel #2
0
func start(ctx *cli.Context) {
	if ctx.Bool("profile") {
		pcfg := profile.Config{
			CPUProfile:   true,
			MemProfile:   true,
			BlockProfile: true,
			ProfilePath:  ".",
		}
		p := profile.Start(&pcfg)
		defer p.Stop()
	}
	initLogrus(ctx)
	log.Info("Starting fullerite...")

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}
	collectors := startCollectors(c)
	handlers := startHandlers(c)

	internalServer := internalserver.New(c, &handlers)
	go internalServer.Run()

	metrics := make(chan metric.Metric)
	readFromCollectors(collectors, metrics)

	hook := NewLogErrorHook(metrics)
	log.Logger.Hooks.Add(hook)

	relayMetricsToHandlers(handlers, metrics)
}
Beispiel #3
0
func start(ctx *cli.Context) {
	if ctx.Bool("profile") {
		pcfg := profile.Config{
			CPUProfile:   true,
			MemProfile:   true,
			BlockProfile: true,
			ProfilePath:  ".",
		}
		p := profile.Start(&pcfg)
		defer p.Stop()
	}
	initLogrus(ctx)
	log.Info("Starting fullerite...")

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}
	collectors := startCollectors(c)
	handlers := startHandlers(c)

	internalServer := internalserver.New(c, &handlers)
	go internalServer.Run()

	metrics := make(chan metric.Metric)
	readFromCollectors(collectors, metrics)
	for metric := range metrics {
		// Writing to handlers' channels. Sending metrics is
		// handled asynchronously in handlers' Run functions.
		writeToHandlers(handlers, metric)
	}
}