hsup

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2015 License: BSD-2-Clause Imports: 35 Imported by: 0

README

hsup

Supervises processes that are configured in a Heroku-esque way.

hsup can poll the Heroku API directly to obtain releases, configuration, and execution information. hsup can also watch a local directory that injects similar information.

The execution is performed with a chosen "dyno driver". The default dyno driver, simple, downloads and refreshes the environment only. There is also a docker dyno driver that both obtains the environment and executable code and runs it interposed on the heroku/cedar:14 image.

Usage:

hsup COMMAND [options] [args...]

Where COMMAND is on one:

  • run: Run a command with an app's environment.
  • start: Start a process type as defined in an app's Procfile.

Example:

godep go install ./...
export DOCKER_HOST=unix:///var/run/docker.sock
export HEROKU_ACCESS_TOKEN=...

# start default process types inside Docker
hsup start -d docker start -a simple-brandur

# run command as subprocess
hsup run -d simple -a simple-brandur -- echo "hello"

Example using a directory:

godep go install ./...
export HSUP_CONTROL_DIR=/tmp/supctl
mkdir -p "$HSUP_CONTROL_DIR"
echo '{
    "Version": 1,
    "Env": {
        "NAME": "CONTENTS"
    },
    "Slug": "sample-slug.tgz",
    "Stack": "cedar-14",
    "Processes": [
        {
            "Args": ["./web-server", "arg"],
            "Quantity": 2,
            "Type": "web"
        },
        {
            "Args": ["./worker", "arg"],
            "Quantity": 2,
            "Type": "worker"
        }
    ]
}' > "$HSUP_CONTROL_DIR"/new
hsup run '/usr/bin/printenv'

# Note that after verifying the input, the file is moved to "loaded".
# Writing new "new" files is how updates can be issued.
ls "$HSUP_CONTROL_DIR"

Documentation

Index

Constants

View Source
const ProfileRunnerText = `` /* 360-byte string literal not displayed */

Variables

View Source
var (
	ErrDriverNotSupported = errors.New(
		"the libcontainer driver is not supported on this platform",
	)
)
View Source
var ErrExecutorComplete = errors.New("Executor complete")
View Source
var ErrNoReleases = errors.New("No releases found")
View Source
var ErrNoSlugURL = errors.New("no slug specified")

Functions

func StartControlAPI

func StartControlAPI(port int, processes <-chan *Processes) <-chan *Processes

Types

type APIFormation

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

func (*APIFormation) Args

func (f *APIFormation) Args() []string

func (*APIFormation) Quantity

func (f *APIFormation) Quantity() int

func (*APIFormation) Type

func (f *APIFormation) Type() string

type APIPoller

type APIPoller struct {
	Cl      *heroku.Service
	App     string
	Dd      DynoDriver
	OneShot bool
	// contains filtered or unexported fields
}

func (*APIPoller) Notify

func (ap *APIPoller) Notify() <-chan *Processes

Listens for new releases by periodically polling the Heroku API. When a new release is detected it is sent to the returned channel.

type AbsPathDynoDriver

type AbsPathDynoDriver struct{}

func (*AbsPathDynoDriver) Build

func (dd *AbsPathDynoDriver) Build(release *Release) (err error)

func (*AbsPathDynoDriver) Start

func (dd *AbsPathDynoDriver) Start(ex *Executor) (err error)

func (*AbsPathDynoDriver) Stop

func (dd *AbsPathDynoDriver) Stop(ex *Executor) error

func (*AbsPathDynoDriver) Wait

func (dd *AbsPathDynoDriver) Wait(ex *Executor) (s *ExitStatus)

type AppSerializable

type AppSerializable struct {
	Version   int
	Env       map[string]string
	Slug      string
	Stack     string
	Processes []FormationSerializable
}

func (*AppSerializable) FromBase64Gob

func (as *AppSerializable) FromBase64Gob(payload string)

func (*AppSerializable) Procs

func (as *AppSerializable) Procs(appName string, dd DynoDriver, oneShot bool) *Processes

func (*AppSerializable) ToBase64Gob

func (as *AppSerializable) ToBase64Gob() string

type ControlAPI

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

func (*ControlAPI) ServeGET

func (c *ControlAPI) ServeGET(w http.ResponseWriter, r *http.Request)

func (*ControlAPI) ServeHTTP

func (c *ControlAPI) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ControlAPI) ServePOST

func (c *ControlAPI) ServePOST(w http.ResponseWriter, r *http.Request)

func (*ControlAPI) Tee

func (c *ControlAPI) Tee(procs <-chan *Processes) <-chan *Processes

type DirPoller

type DirPoller struct {
	Dd      DynoDriver
	Dir     string
	AppName string
	OneShot bool
	// contains filtered or unexported fields
}

func (*DirPoller) Notify

func (dp *DirPoller) Notify() <-chan *Processes

type Docker

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

func (*Docker) BuildSlugImage

func (d *Docker) BuildSlugImage(si *DockerStackImage, release *Release) (
	string, error)

func (*Docker) Connect

func (d *Docker) Connect() (err error)

func (*Docker) StackStat

func (d *Docker) StackStat(stack string) (*DockerStackImage, error)

type DockerDynoDriver

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

func (*DockerDynoDriver) Build

func (dd *DockerDynoDriver) Build(release *Release) error

func (*DockerDynoDriver) Start

func (dd *DockerDynoDriver) Start(ex *Executor) error

func (*DockerDynoDriver) Stop

func (dd *DockerDynoDriver) Stop(ex *Executor) error

func (*DockerDynoDriver) Wait

func (dd *DockerDynoDriver) Wait(ex *Executor) (s *ExitStatus)

type DockerStackImage

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

type DynoDriver

type DynoDriver interface {
	Build(*Release) error
	Start(*Executor) error
	Stop(*Executor) error
	Wait(*Executor) *ExitStatus
}

type DynoInput

type DynoInput int
const (
	Retire DynoInput = iota
	Restart
	Exited
	StayStarted
)

func (DynoInput) String

func (i DynoInput) String() string

type DynoState

type DynoState int
const (
	Stopped DynoState = iota
	Started
	Retiring
	Retired
)

func (DynoState) String

func (i DynoState) String() string

type Executor

type Executor struct {
	Args        []string
	DynoDriver  DynoDriver
	Release     *Release
	ProcessID   string
	ProcessType string
	Status      chan *ExitStatus
	Complete    chan struct{}

	// FSM Fields
	OneShot  bool
	State    DynoState
	NewInput chan DynoInput
	// contains filtered or unexported fields
}

func (*Executor) Name

func (e *Executor) Name() string

func (*Executor) Tick

func (e *Executor) Tick() (err error)

func (*Executor) Trigger

func (e *Executor) Trigger(input DynoInput)

type ExitStatus

type ExitStatus struct {
	Code int
	Err  error
}

type Formation

type Formation interface {
	Args() []string
	Quantity() int
	Type() string
}

type FormationSerializable

type FormationSerializable struct {
	FArgs     []string `json:"Args"`
	FQuantity int      `json:"Quantity"`
	FType     string   `json:"Type"`
}

func (*FormationSerializable) Args

func (fs *FormationSerializable) Args() []string

func (*FormationSerializable) Quantity

func (fs *FormationSerializable) Quantity() int

func (*FormationSerializable) Type

func (fs *FormationSerializable) Type() string

type GobNotifier

type GobNotifier struct {
	Dd      DynoDriver
	AppName string
	OneShot bool

	Payload string
}

func (*GobNotifier) Notify

func (gn *GobNotifier) Notify() <-chan *Processes

type LibContainerDynoDriver

type LibContainerDynoDriver struct{}

func NewLibContainerDynoDriver

func NewLibContainerDynoDriver(string) (*LibContainerDynoDriver, error)

func (*LibContainerDynoDriver) Build

func (dd *LibContainerDynoDriver) Build(*Release) error

func (*LibContainerDynoDriver) Start

func (*LibContainerDynoDriver) Stop

func (*LibContainerDynoDriver) Wait

type LibContainerInitDriver

type LibContainerInitDriver struct{}

func (*LibContainerInitDriver) Build

func (dd *LibContainerInitDriver) Build(*Release) error

func (*LibContainerInitDriver) Start

func (*LibContainerInitDriver) Stop

func (*LibContainerInitDriver) Wait

type Notifier

type Notifier interface {
	Notify() <-chan *Processes
}

type Processes

type Processes struct {
	Rel   *Release
	Forms []Formation

	Dd        DynoDriver
	OneShot   bool
	Executors []*Executor
}

type ProfileRunner

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

func (*ProfileRunner) Args

func (pr *ProfileRunner) Args(args []string) []string

func (*ProfileRunner) Init

func (pr *ProfileRunner) Init() (err error)

type Release

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

func (*Release) ConfigSlice

func (r *Release) ConfigSlice() []string

func (*Release) Name

func (r *Release) Name() string

func (*Release) Where

func (r *Release) Where() SlugWhere

type SimpleDynoDriver

type SimpleDynoDriver struct {
}

func (*SimpleDynoDriver) Build

func (dd *SimpleDynoDriver) Build(release *Release) error

func (*SimpleDynoDriver) Start

func (dd *SimpleDynoDriver) Start(ex *Executor) error

func (*SimpleDynoDriver) Stop

func (dd *SimpleDynoDriver) Stop(ex *Executor) error

func (*SimpleDynoDriver) Wait

func (dd *SimpleDynoDriver) Wait(ex *Executor) (s *ExitStatus)

type SlugWhere

type SlugWhere int
const (
	Local SlugWhere = iota
	HTTP
)

type StatusResponse

type StatusResponse struct {
	Processes map[string]string
}

type StopRequest

type StopRequest struct {
	Processes []string
}

type StopResponse

type StopResponse struct {
	StoppedProcesses []string
}

Directories

Path Synopsis
Godeps
_workspace/src/bitbucket.org/kardianos/osext
Extensions to the standard "os" package.
Extensions to the standard "os" package.
_workspace/src/code.google.com/p/go-uuid/uuid
The uuid package generates and inspects UUIDs.
The uuid package generates and inspects UUIDs.
_workspace/src/github.com/coreos/go-systemd/dbus
Integration with the systemd D-Bus API.
Integration with the systemd D-Bus API.
_workspace/src/github.com/cyberdelia/heroku-go/v3
Generated service client for heroku API.
Generated service client for heroku API.
_workspace/src/github.com/docker/docker/pkg/pools
Package pools provides a collection of pools which provide various data types with buffers.
Package pools provides a collection of pools which provide various data types with buffers.
_workspace/src/github.com/docker/libcontainer
Temporary API endpoint for libcontainer while the full API is finalized (api.go).
Temporary API endpoint for libcontainer while the full API is finalized (api.go).
_workspace/src/github.com/docker/libcontainer/integration
integration is used for integration testing of libcontainer
integration is used for integration testing of libcontainer
_workspace/src/github.com/docker/libcontainer/netlink
Packet netlink provide access to low level Netlink sockets and messages.
Packet netlink provide access to low level Netlink sockets and messages.
_workspace/src/github.com/fsouza/go-dockerclient
Package docker provides a client for the Docker remote API.
Package docker provides a client for the Docker remote API.
_workspace/src/github.com/fsouza/go-dockerclient/testing
Package testing provides a fake implementation of the Docker API, useful for testing purpose.
Package testing provides a fake implementation of the Docker API, useful for testing purpose.
_workspace/src/github.com/godbus/dbus
Package dbus implements bindings to the D-Bus message bus system.
Package dbus implements bindings to the D-Bus message bus system.
_workspace/src/github.com/godbus/dbus/introspect
Package introspect provides some utilities for dealing with the DBus introspection format.
Package introspect provides some utilities for dealing with the DBus introspection format.
_workspace/src/github.com/godbus/dbus/prop
Package prop provides the Properties struct which can be used to implement org.freedesktop.DBus.Properties.
Package prop provides the Properties struct which can be used to implement org.freedesktop.DBus.Properties.
_workspace/src/github.com/ogier/pflag
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
_workspace/src/github.com/syndtr/gocapability/capability
Package capability provides utilities for manipulating POSIX capabilities.
Package capability provides utilities for manipulating POSIX capabilities.
_workspace/src/gopkg.in/yaml.v2
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.
cmd

Jump to

Keyboard shortcuts

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