server

package
v0.0.0-...-2bd953d Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GracefullyRemoveDockerContainer

func GracefullyRemoveDockerContainer(ctx context.Context, containerID string) error

func RemoveDockerContainer

func RemoveDockerContainer(ctx context.Context, containerID string) error

RemoveContainer stops and removes a container, but be warned that this will not remove the container from the database

func RemoveVolume

func RemoveVolume(ctx context.Context, volumeID string) error

func WaitForDockerContainer

func WaitForDockerContainer(ctx context.Context, containerID string, containerPort uint16) error

scuffed af "health check" for docker containers

Types

type App

type App struct {
	ID           int64       `json:"id,omitempty"`
	Deployment   *Deployment `json:"-"`
	Name         string      `json:"name,omitempty"`
	DeploymentID int64       `json:"deployment_id,omitempty"`
}

func CreateApp

func CreateApp(ctx context.Context, imageName string, projectPath string, projectConfig pkg.ProjectConfig) (*App, error)

func (*App) Remove

func (app *App) Remove(ctx context.Context) error

func (*App) Upgrade

func (app *App) Upgrade(ctx context.Context, projectConfig pkg.ProjectConfig, imageName string, projectPath string) error

type AppManager

type AppManager struct {
	sync.Map
}

func (*AppManager) AddApp

func (am *AppManager) AddApp(name string, app *App)

func (*AppManager) DeleteApp

func (am *AppManager) DeleteApp(name string) error

func (*AppManager) GetAllApps

func (am *AppManager) GetAllApps() []*App

func (*AppManager) GetApp

func (am *AppManager) GetApp(name string) *App

func (*AppManager) Init

func (am *AppManager) Init()

func (*AppManager) RemoveApp

func (am *AppManager) RemoveApp(name string)

type Container

type Container struct {
	ID           int64       `json:"id"`
	Head         bool        `json:"head"` // if the container is the head of the deployment
	Deployment   *Deployment `json:"-"`
	Volumes      []Volume    `json:"volumes"`
	ContainerID  [64]byte    `json:"container_id"`
	DeploymentID int64       `json:"deployment_id"`
}

func CreateContainer

func CreateContainer(ctx context.Context, imageName, projectPath string, projectConfig pkg.ProjectConfig, head bool, deployment *Deployment) (c *Container, err error)

func CreateDockerContainer

func CreateDockerContainer(ctx context.Context, imageName, projectPath string, projectConfig pkg.ProjectConfig, vol *Volume) (*Container, error)

func (*Container) Remove

func (c *Container) Remove(ctx context.Context) error

func (*Container) Start

func (c *Container) Start(ctx context.Context) error

func (*Container) Status

func (c *Container) Status(ctx context.Context) (string, error)

func (*Container) Stop

func (c *Container) Stop(ctx context.Context) error

func (*Container) Upgrade

func (c *Container) Upgrade(ctx context.Context, imageName, projectPath string, projectConfig pkg.ProjectConfig) (*Container, error)

func (*Container) Wait

func (c *Container) Wait(ctx context.Context, port uint16) error

type DeployRequest

type DeployRequest struct {
	Config multipart.File `form:"config"`
	Code   multipart.File `form:"code"`
}

type DeployResponse

type DeployResponse struct {
	App App `json:"app"`
}

type Deployment

type Deployment struct {
	ID         int64            `json:"id"`
	Head       *Container       `json:"head,omitempty"`
	Containers []*Container     `json:"containers,omitempty"`
	Proxy      *DeploymentProxy `json:"-"`
	URL        string           `json:"url"`
	Port       uint16           `json:"port"`
}

func CreateDeployment

func CreateDeployment(port uint16, appUrl string, db *sql.DB) (*Deployment, error)

Creates a deployment and containers in the database

func (*Deployment) NewDeploymentProxy

func (deployment *Deployment) NewDeploymentProxy() (*DeploymentProxy, error)

func (*Deployment) Remove

func (d *Deployment) Remove(ctx context.Context) error

func (*Deployment) Start

func (d *Deployment) Start(ctx context.Context) error

func (*Deployment) Status

func (d *Deployment) Status(ctx context.Context) (string, error)

func (*Deployment) Stop

func (d *Deployment) Stop(ctx context.Context) error

func (*Deployment) Upgrade

func (deployment *Deployment) Upgrade(ctx context.Context, projectConfig pkg.ProjectConfig, imageName string, projectPath string) error

type DeploymentEvent

type DeploymentEvent struct {
	Stage      string      `json:"stage"`
	Message    interface{} `json:"message"`
	StatusCode int         `json:"status,omitempty"`
}

type DeploymentLock

type DeploymentLock struct {
	// contains filtered or unexported fields
}

func NewDeploymentLock

func NewDeploymentLock() *DeploymentLock

func (*DeploymentLock) CompleteDeployment

func (dt *DeploymentLock) CompleteDeployment(appName string)

func (*DeploymentLock) StartDeployment

func (dt *DeploymentLock) StartDeployment(appName string, ctx context.Context) (context.Context, error)

type DeploymentProxy

type DeploymentProxy struct {
	// contains filtered or unexported fields
}

func (*DeploymentProxy) GracefulShutdown

func (dp *DeploymentProxy) GracefulShutdown(oldContainers []*Container)

type FluxServer

type FluxServer struct {
	Logger *zap.SugaredLogger
	// contains filtered or unexported fields
}
var (
	DefaultConfig = FluxServerConfig{
		Builder: "paketobuildpacks/builder-jammy-tiny",
		Compression: pkg.Compression{
			Enabled: false,
			Level:   0,
		},
	}
	Flux *FluxServer
)

func NewFluxServer

func NewFluxServer() *FluxServer

func NewServer

func NewServer() *FluxServer

func (*FluxServer) DaemonInfoHandler

func (s *FluxServer) DaemonInfoHandler(w http.ResponseWriter, r *http.Request)

func (*FluxServer) DeleteAllDeploymentsHandler

func (s *FluxServer) DeleteAllDeploymentsHandler(w http.ResponseWriter, r *http.Request)

func (*FluxServer) DeleteDeployHandler

func (s *FluxServer) DeleteDeployHandler(w http.ResponseWriter, r *http.Request)

func (*FluxServer) DeployHandler

func (s *FluxServer) DeployHandler(w http.ResponseWriter, r *http.Request)

func (*FluxServer) ListAppsHandler

func (s *FluxServer) ListAppsHandler(w http.ResponseWriter, r *http.Request)

func (*FluxServer) StartDeployHandler

func (s *FluxServer) StartDeployHandler(w http.ResponseWriter, r *http.Request)

func (*FluxServer) Stop

func (s *FluxServer) Stop()

func (*FluxServer) StopDeployHandler

func (s *FluxServer) StopDeployHandler(w http.ResponseWriter, r *http.Request)

func (*FluxServer) UploadAppCode

func (s *FluxServer) UploadAppCode(code io.Reader, projectConfig pkg.ProjectConfig) (string, error)

type FluxServerConfig

type FluxServerConfig struct {
	Builder     string          `json:"builder"`
	Compression pkg.Compression `json:"compression"`
}

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

func (*Proxy) AddDeployment

func (p *Proxy) AddDeployment(deployment *Deployment)

func (*Proxy) RemoveDeployment

func (p *Proxy) RemoveDeployment(deployment *Deployment)

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Volume

type Volume struct {
	ID          int64  `json:"id"`
	VolumeID    string `json:"volume_id"`
	Mountpoint  string `json:"mountpoint"`
	ContainerID string `json:"container_id"`
}

func CreateDockerVolume

func CreateDockerVolume(ctx context.Context) (vol *Volume, err error)

Jump to

Keyboard shortcuts

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