Example #1
0
func startShaman(ccmd *cobra.Command, args []string) error {
	config.Log = lumber.NewConsoleLogger(lumber.LvlInt(config.LogLevel))

	// initialize cache
	err := cache.Initialize()
	if err != nil {
		config.Log.Fatal(err.Error())
		return err
	}

	// make channel for errors
	errors := make(chan error)

	go func() {
		errors <- api.Start()
	}()
	go func() {
		errors <- server.Start()
	}()

	// break if any of them return an error (blocks exit)
	if err := <-errors; err != nil {
		config.Log.Fatal(err.Error())
	}
	return err
}
Example #2
0
func TestMain(m *testing.M) {
	// manually configure
	initialize()

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

	os.Exit(rtn)
}