app

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ShellBackgroundCommand = []string{
	"/bin/sh",
	"-c",
	strings.Join([]string{

		"EXPECTED_PROCS=\"$(ls -1 /proc | grep -c [0-9])\"",
		"STOP=$(($(date +%s)+" + fmt.Sprintf("%d", maxLifetime) + "))",

		"sleep " + fmt.Sprintf("%d", waitForConnect),

		"while true",
		"do PROCS=\"$(ls -1 /proc | grep -c [0-9])\"",
		"test \"$PROCS\" -le \"$EXPECTED_PROCS\" && exit",

		"test \"$STOP\" -lt \"$(date +%s)\" && exit 1",
		"sleep 30",
		"done",
	}, "; "),
}

Functions

This section is empty.

Types

type App

type App struct {
	Name                  string
	Session               *session.Session
	Settings              *Settings
	ECSConfig             *ECSConfig
	DeployStatus          *DeployStatus
	PendingDeployStatuses []*DeployStatus
}

App is a representation of a AppPack app

func Init

func Init(name string) (*App, error)

Init will pull in app settings from DyanmoDB and provide helper

func (*App) BuildStatus

func (a *App) BuildStatus(build *codebuild.Build) (*DeployStatus, error)

BuildStatus checks the status of a CodeBuild run

func (*App) ConnectToTask

func (a *App) ConnectToTask(task *ecs.Task, cmd *string) error

ConnectToTask open a SSM Session to the Docker host and exec into container

func (*App) CreateScheduledTask

func (a *App) CreateScheduledTask(schedule string, command string) ([]*ScheduledTask, error)

CreateScheduledTask adds a scheduled task for the app

func (*App) DeleteScheduledTask

func (a *App) DeleteScheduledTask(idx int) (*ScheduledTask, error)

DeleteScheduledTask deletes the scheduled task at the given index

func (*App) DescribeTasks

func (a *App) DescribeTasks() ([]*ecs.Task, error)

DescribeTasks generate a URL which will sign the user in to the AWS console and redirect to the desinationURL

func (*App) GetBuildArtifact

func (a *App) GetBuildArtifact(build *codebuild.Build, name string) ([]byte, error)

GetBuildArtifact retrieves an artifact stored in S3

func (*App) GetConfig added in v1.2.0

func (a *App) GetConfig() ([]*ssm.Parameter, error)

GetConfig returns a list of config parameters for the app

func (*App) GetConsoleURL

func (a *App) GetConsoleURL(destinationURL string) (*string, error)

GetConsoleURL generate a URL which will sign the user in to the AWS console and redirect to the desinationURL

func (*App) GetDeployStatus

func (a *App) GetDeployStatus(buildARN string) (*DeployStatus, error)

GetDeployStatus will get a DeployStatus value from DDB

func (*App) LastBuild

func (a *App) LastBuild() (*codebuild.Build, error)

LastBuild retrieves the most recent build

func (*App) ListBuilds

func (a *App) ListBuilds() ([]*codebuild.Build, error)

ListBuilds lists recent CodeBuild runs

func (*App) LoadDeployStatus

func (a *App) LoadDeployStatus() error

LoadDeployStatus will set the app.DeployStatus value from DDB

func (*App) LoadECSConfig

func (a *App) LoadECSConfig() error

LoadECSConfig will set the app.ECSConfig value from DDB

func (*App) LoadSettings

func (a *App) LoadSettings() error

LoadSettings will set the app.Settings value from DDB

func (*App) ResizeProcess

func (a *App) ResizeProcess(processType string, cpu int, memory int) error

func (*App) ScaleProcess

func (a *App) ScaleProcess(processType string, minProcessCount int, maxProcessCount int) error

func (*App) ScheduledTasks

func (a *App) ScheduledTasks() ([]*ScheduledTask, error)

ScheduledTasks lists scheduled tasks for the app

func (*App) SetConfig added in v1.2.0

func (a *App) SetConfig(key string, value string, overwrite bool) error

SetConfig sets a config value for the app

func (*App) StartBuild

func (a *App) StartBuild() (*codebuild.Build, error)

StartBuild starts a new CodeBuild run

func (*App) StartTask

func (a *App) StartTask(taskFamily *string, command []string, fargate bool) (*ecs.RunTaskOutput, error)

StartTask start a new task on ECS

func (*App) ValidateCronString

func (a *App) ValidateCronString(rule string) error

ValidateCronString validates a cron schedule rule

func (*App) WaitForTaskRunning

func (a *App) WaitForTaskRunning(task *ecs.Task) error

WaitForTaskRunning waits for a task to be running or complete

func (*App) WaitForTaskStopped

func (a *App) WaitForTaskStopped(task *ecs.Task) error

WaitForTaskStopped waits for a task to be running or complete

type DeployStatus

type DeployStatus struct {
	Phase       string             `json:"phase"`
	Processes   map[string]Process `json:"processes"`
	BuildID     string             `json:"build_id"`
	LastUpdate  int64              `json:"last_update"`
	Commit      string             `json:"commit"`
	BuildNumber int                `json:"build_number"`
	Failed      bool               `json:"failed"`
}

type ECSConfig

type ECSConfig struct {
	RunTaskArgs        ecs.RunTaskInput `locationName:"run_task_args"`
	RunTaskArgsFargate ecs.RunTaskInput `locationName:"run_task_args_fargate"`
}

type Process

type Process struct {
	CPU          string `json:"cpu"`
	Memory       string `json:"memory"`
	MinProcesses int    `json:"min_processes"`
	MaxProcesses int    `json:"max_processes"`
	State        string `json:"state"`
	Command      string `json:"command"`
}

type Scaling

type Scaling struct {
	CPU          int `json:"cpu"`
	Memory       int `json:"memory"`
	MinProcesses int `json:"min_processes"`
	MaxProcesses int `json:"max_processes"`
}

type ScheduledTask

type ScheduledTask struct {
	Schedule string `json:"schedule"`
	Command  string `json:"command"`
}

type Settings

type Settings struct {
	Cluster struct {
		ARN  string `json:"arn"`
		Name string `json:"name"`
	} `json:"cluster"`
	Domains []string `json:"domains"`
	Shell   struct {
		Command    string `json:"command"`
		TaskFamily string `json:"task_family"`
	} `json:"shell"`
	DBUtils struct {
		ShellTaskFamily    string `json:"shell_task_family"`
		S3Bucket           string `json:"s3_bucket"`
		DumpLoadTaskFamily string `json:"dumpload_task_family"`
		Engine             string `json:"engine"`
	} `json:"dbutils"`
	CodebuildProject struct {
		Name string `json:"name"`
	} `json:"codebuild_project"`
	LogGroup struct {
		Name string `json:"name"`
	} `json:"log_group"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL