Ejemplo n.º 1
0
func startLogvac(ccmd *cobra.Command, args []string) error {
	// initialize logger
	lumber.Level(lumber.LvlInt(config.LogLevel)) // for clients using lumber too
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt(config.LogLevel))

	// initialize logvac
	logvac.Init()

	// setup authenticator
	err := authenticator.Init()
	if err != nil {
		return fmt.Errorf("Authenticator failed to initialize - %v", err)
	}

	// initialize drains
	err = drain.Init()
	if err != nil {
		return fmt.Errorf("Drain failed to initialize - %v", err)
	}

	// initializes collectors
	err = collector.Init()
	if err != nil {
		return fmt.Errorf("Collector failed to initialize - %v", err)
	}

	err = api.Start(collector.CollectHandler)
	if err != nil {
		return fmt.Errorf("Api failed to initialize - %v", err)
	}

	return nil
}
Ejemplo n.º 2
0
func TestMain(m *testing.M) {
	// clean test dir
	os.RemoveAll("/tmp/apiTest")

	// manually configure
	initialize()

	// start insecure api
	config.Token = ""
	go api.Start(collector.CollectHandler)
	time.Sleep(time.Second)
	// start secure api
	config.Token = "secret"
	config.Insecure = false
	config.ListenHttp = secureHttp
	go api.Start(collector.CollectHandler)
	<-time.After(time.Second)
	rtn := m.Run()

	// clean test dir
	os.RemoveAll("/tmp/apiTest")

	os.Exit(rtn)
}
Ejemplo n.º 3
0
func TestMain(m *testing.M) {
	// clean test dir
	os.RemoveAll("/tmp/syslogTest")

	// manually configure
	initialize()

	// start api
	config.Token = ""
	go api.Start(collector.CollectHandler)
	<-time.After(1 * time.Second)
	rtn := m.Run()

	// clean test dir
	os.RemoveAll("/tmp/syslogTest")

	os.Exit(rtn)
}
Ejemplo n.º 4
0
func TestMain(m *testing.M) {
	// clean test dir
	os.RemoveAll("/tmp/authTest")

	// manually configure
	err := initialize()
	if err != nil {
		os.Exit(1)
	}

	// start api
	go api.Start(collector.CollectHandler)
	<-time.After(1 * time.Second)
	rtn := m.Run()

	// clean test dir
	os.RemoveAll("/tmp/authTest")

	os.Exit(rtn)
}