Exemple #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
}
Exemple #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)
}
Exemple #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)
}
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)
}