Total Pageviews

Tuesday 4 October 2016

基于ruby的部署工具-Deployinator



Deployinator - Deploy code like Etsy
Deployinator is a deployment framework extracted from Etsy. We've been using it since late 2009 / early 2010. This has been revamped into a ruby gem.

Stacks
Deployments are grouped by "stacks". You might have a "web" and "search" stack.
Each of those stacks might have different deployment environments, such as "staging" or "production".
You can map a button to each of these environments, to create multi-stage pushes within each stack.

Installation
This demo assumes you are using bundler to install deployinator. If you aren't you can skip the bundler steps.
  • Create a directory for your project to hold your specific code (outside of the gem and this will be your own internal repository). mkdir test_stacks
  • Create a Gemfile for bundler:
    source 'https://rubygems.org'
    gem 'etsy-deployinator', :git => 'https://github.com/etsy/deployinator.git', :branch => 'master', :require => 'deployinator'
  • Install all required gems with bundler:
    $ bundle install --path vendor/bundle
  • Run the following command to make deployinator gem's rake tasks available to you:
    $ shopt -s xpg_echo
    $ echo "require 'deployinator'\nload 'deployinator/tasks/initialize.rake' " > Rakefile
  • Create a binstub for the deploy log tailing backend:
    bundle binstub etsy-deployinator
  • Initialize the project directory by running the following command replacing Company with the name of your company/organization. This must start with a capital letter.
    $ bundle exec rake 'deployinator:init[Company]'
  • Run the tailer as a background service (using whatever init flavor you like)
    ./bin/deployinator-tailer.rb &

Usage

Example Stack
  • Use the deployinator rake task to create the stub for your stack. Replace test_stack with the name of your stack. This should be all lowercase with underscores but if you forget the rake task will convert from camelcase for you. The commands run by the rake tasks are logged to stderr.
    $ bundle exec rake 'deployinator:new_stack[test_stack]'
  • We need a server to run our Sinatra application. For the purpose of this demo, we will use puma. Let's install puma into our bundle. Add the following to your Gemfile:
    gem 'puma'
  • Now update your bundler:
    bundle install --path vendor/bundle --no-deployment && bundle install --path vendor/bundle --deployment
  • Start the server by running:
    • The host could be localhost or the dns name (or ip address of the server you are using). You can set any port you want that's not in use using the -p flag.
    $ bundle exec puma -b tcp://0.0.0.0:7777 config.ru

  • You will probably want a robust server like apache to handle production traffic.
  • The config/base.rb file is the base config for the application. Replace all occurences of test_stack with the name you chose above. 
from https://github.com/etsy/deployinator/