예제 #1
0
파일: main.go 프로젝트: koding/koding
func main() {
	var cfg kloud.Config

	kloudErr := config.Load(&cfg)

	var schemaCfg SchemaConfig

	if err := config.Load(&schemaCfg); err == nil && schemaCfg.GenSchema != "" {
		if err := genSchema(schemaCfg.GenSchema); err != nil {
			log.Fatal(err)
		}

		return
	}

	if kloudErr != nil {
		log.Fatal(kloudErr)
	}

	// Load the config, it's reads environment variables or from flags
	if cfg.Version {
		fmt.Println(stack.VERSION)
		os.Exit(0)
	}

	k, err := kloud.New(&cfg)
	if err != nil {
		log.Fatal(err)
	}

	stack.Konfig = konfig.NewKonfig(&konfig.Environments{
		Env: k.Kite.Config.Environment,
	})

	// DataDog listens to it
	go func() {
		err := http.ListenAndServe("0.0.0.0:6060", nil)
		if err != nil {
			log.Fatal(err)
		}
	}()

	k.Kite.Run()
}
예제 #2
0
파일: main_test.go 프로젝트: koding/koding
func kloudWithProviders(a *awsprovider.Provider, s *softlayer.Provider) *kloud.Kloud {
	kloudLogger := logging.NewCustom("kloud", true)
	sess := &session.Session{
		DB:         a.DB,
		Kite:       a.Kite,
		DNSClient:  a.DNSClient,
		DNSStorage: a.DNSStorage,
		AWSClients: a.EC2Clients,
		Userdata:   a.Userdata,
		Log:        kloudLogger,
	}

	kld := kloud.New()
	kld.ContextCreator = func(ctx context.Context) context.Context {
		return session.NewContext(ctx, sess)
	}

	userPrivateKey, userPublicKey := userMachinesKeys(
		os.Getenv("KLOUD_USER_PUBLICKEY"),
		os.Getenv("KLOUD_USER_PRIVATEKEY"),
	)

	kld.PublicKeys = &publickeys.Keys{
		KeyName:    publickeys.DeployKeyName,
		PrivateKey: userPrivateKey,
		PublicKey:  userPublicKey,
	}
	kld.Log = kloudLogger
	kld.DomainStorage = p.DNSStorage
	kld.Domainer = p.DNSClient
	kld.Locker = p
	kld.AddProvider("koding", p)
	kld.AddProvider("aws", a)
	kld.AddProvider("softlayer", s)
	return kld
}