示例#1
0
func StartHeartbeat() {
	log := logger.New("ns=heartbeat")
	defer recoverWith(func(err error) {
		helpers.Error(log, err)
	})

	helpers.SendMixpanelEvent("kernel-heartbeat", "")

	for _ = range time.Tick(1 * time.Hour) {
		helpers.SendMixpanelEvent("kernel-heartbeat", "")
	}
}
示例#2
0
文件: app.go 项目: jbuck/rack
func (a *App) Delete() error {
	helpers.SendMixpanelEvent("kernel-app-delete-start", "")

	name := a.Name

	_, err := CloudFormation().DeleteStack(&cloudformation.DeleteStackInput{StackName: aws.String(name)})

	if err != nil {
		helpers.SendMixpanelEvent("kernel-app-delete-error", "")
		return err
	}

	go a.Cleanup()

	helpers.SendMixpanelEvent("kernel-app-delete-success", "")

	return nil
}
示例#3
0
文件: app.go 项目: jbuck/rack
func (a *App) Create() error {
	helpers.SendMixpanelEvent("kernel-app-create-start", "")

	if len(a.Name) < 2 {
		helpers.SendMixpanelEvent("kernel-app-create-error", "")
		return fmt.Errorf("invalid app name")
	}

	formation, err := a.Formation()

	if err != nil {
		helpers.SendMixpanelEvent("kernel-app-create-error", "")
		return err
	}

	params := map[string]string{
		"Cluster": os.Getenv("CLUSTER"),
		"Subnets": os.Getenv("SUBNETS"),
		"Version": os.Getenv("RELEASE"),
		"VPC":     os.Getenv("VPC"),
	}

	if os.Getenv("ENCRYPTION_KEY") != "" {
		params["Key"] = os.Getenv("ENCRYPTION_KEY")
	}

	tags := map[string]string{
		"System": "convox",
		"Type":   "app",
	}

	req := &cloudformation.CreateStackInput{
		Capabilities: []*string{aws.String("CAPABILITY_IAM")},
		StackName:    aws.String(a.Name),
		TemplateBody: aws.String(formation),
	}

	for key, value := range params {
		req.Parameters = append(req.Parameters, &cloudformation.Parameter{
			ParameterKey:   aws.String(key),
			ParameterValue: aws.String(value),
		})
	}

	for key, value := range tags {
		req.Tags = append(req.Tags, &cloudformation.Tag{
			Key:   aws.String(key),
			Value: aws.String(value),
		})
	}

	_, err = CloudFormation().CreateStack(req)

	if err != nil {
		helpers.SendMixpanelEvent("kernel-app-create-error", "")
		return err
	}

	helpers.SendMixpanelEvent("kernel-app-create-success", "")
	return nil
}