stretcher

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2014 License: MIT Imports: 19 Imported by: 0

README

stretcher

A deployment tool with consul event.

example manifest

src: s3://example.com/app.tar.gz
checksum: e0840daaa97cd2cf2175f9e5d133ffb3324a2b93
dest: /home/stretcher/app
commands:
  pre:
    - echo 'staring deploy'
  post:
    - echo 'deploy done'
excludes:
  - "*.pid"
  - "*.socket"

run

stretcher agent

A stretcher agent is designed as running under "consul watch" and will be kicked by consul event.

When you use S3 URL, export AWS_CONFIG_FILE environment variable.

$ export AWS_CONFIG_FILE=/path/to/.aws/config
$ consul watch -type event -name deploy /path/to/stretcher
  • -name: your deployment identifiy name.
deployment process
preparing
  1. Create tar(or tar.gz) archive for deployment.
  2. Upload the archive file to remote server (S3 or HTTP(S)).
  3. Create a manifest file (YAML) and upload it to remote server.
  • src: archive URL.
  • checksum: archive file's checksum. (md5, sha1, sha256 or sha512 hex format)
  • dest: destination directory path.
  • commands:
    • pre: commands to be executed at before the archive extracted.
    • post: commands to be executed at after the archive extracted.
executing
  1. Create a consul event.
$ consul event -name deploy s3://example.com/deploy-20141117-112233.yml
  • -name: same as stretcher agent event name.
  • payload: manifest URL.
  1. (agent)
  2. Fetching event from consul watch.
  3. Get manifest URL.
  4. Get src URL and store to tmporary directory (by os.TempDir()) and Check checksum.
  5. Invoke pre commands.
  6. Extract src archive to temporary directory.
  7. Sync files from extracted archive to dest directory * by rsync -a --delete
  8. Invoke post commands.

Manifest spec

src
  • Source archive URL.
  • URL schema: 's3', 'http', 'file'
  • Format: 'tar', 'tar.gz'
src: http://example.com/src/archive.tar.gz
checksum
  • Checksum of source archive.
  • Type: 'md5', 'sha1', 'sha256', 'sha512'
checksum: e0840daaa97cd2cf2175f9e5d133ffb3324a2b93
dest
  • Destination directory.
dest: /home/stretcher/app
commands
  • pre: Commands which will be invoked at before src archive extracted.
  • post: Commands which will be invoked at after dest directory synced.
commands:
  pre:
    - echo 'staring deploy'
  post:
    - echo 'deploy done'
excludes
  • Pass to rsync --exclude arguments.
excludes:
  - "*.pid"
  - "*.socket"
exclude_from
  • Pass to rsync --exclude-from arguments.
  • The file must be included in src archive.
excludes_from: exclude.list

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AWSAuth   aws.Auth
	AWSRegion aws.Region
)
View Source
var RsyncDefaultOpts = []string{"-av", "--delete"}

Functions

func LoadAWSConfigFile

func LoadAWSConfigFile(file string) error

func Run

func Run()

Types

type Commands

type Commands struct {
	Pre  []string `yaml:"pre"`
	Post []string `yaml:"post"`
}

type ConsulEvent

type ConsulEvent struct {
	ID      string `json:"ID"`
	Name    string `json:"Name"`
	Payload string `json:"Payload"`
	LTime   int    `json:"LTime"`
}

func ParseConsulEvents

func ParseConsulEvents(in io.Reader) (*ConsulEvent, error)

func (ConsulEvent) PayloadString

func (ev ConsulEvent) PayloadString() string

type ConsulEvents

type ConsulEvents []ConsulEvent

type Manifest

type Manifest struct {
	Src         string   `yaml:"src"`
	CheckSum    string   `yaml:"checksum"`
	Dest        string   `yaml:"dest"`
	Commands    Commands `yaml:"commands"`
	Excludes    []string `yaml:"excludes"`
	ExcludeFrom string   `yaml:"exclude_from"`
}

func ParseManifest

func ParseManifest(data []byte) (*Manifest, error)

func (*Manifest) Deploy

func (m *Manifest) Deploy() error

func (*Manifest) InvokePostDeployCommands

func (m *Manifest) InvokePostDeployCommands() error

func (*Manifest) InvokePreDeployCommands

func (m *Manifest) InvokePreDeployCommands() error

Directories

Path Synopsis
cmd
stretcher command

Jump to

Keyboard shortcuts

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