Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building production server of ruby on modern way

Building production server of ruby on modern way

LT at #rubyconftw2012

Shinya Tsunematsu

December 31, 2012
Tweet

More Decks by Shinya Tsunematsu

Other Decks in Programming

Transcript

  1. Building production server of ruby on modern way RubyConf Taiwan

    2012 Shinya Tsunematsu ( @tnmt ) @ paperboy&co. Inc,
  2. system administrator’s melancholy • we mainly use RHEL clone distributions

    (CentOS, Scientific Linux) • they of course use rpm as their package system. • packaging newly rpm of ruby is hard • packaging rpm is troublesome job • It’s hard to upgrade ruby version using rpm • It’s very very hard to manage rubygem by using ( packaging into ) rpm • packaging rpm, packaging gem, packaging, packageng......
  3. using rbenv at production server • rbenv • https://github.com/sstephenson/rbenv •

    well known convenient tool to develop ruby • we put rbenv at /usr/local/rbenv ( system-wide ) on production server • everyone who logged in server can use common rbenv environment • we try to use Puppet to place benv
  4. rbenv directory tree • /usr/local/rbenv/versions/ • 1.9.3-p327 • 2.0.0-preview1 •

    we can install another version of ruby by distributing files under /usr/local/rbenv/versions/ ( not using `rbenv install 1.9.3-pXXX` ) • using Puppet to distribute files
  5. installing specific ruby version Overview puppet master target server 1.

    puppet agent run 2. get tar ball of specific ruby version
  6. installing specific ruby version Overview puppet master target server 1.

    puppet agent run 2. get tar ball of specific ruby version 3. expand tar ball under /usr/local/rbenv/versions
  7. rbenv module of puppet • Install rbenv • place rbenv

    to /usr/local/rbenv • Install specific ruby version • distribute file ( tar.gz, which contains specific version of ruby ) • expands tar.gz under /usr/local/rbenv/versions • specify default version to /usr/local/rbenv version
  8. How to manage gem ? • gem are installed into

    /usr/local/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems • /usr/local/rbenv/versions/1.9.3-p327/ are managed by puppet and compressed in tar ball • how to add gem’s files to tar ball ?
  9. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide
  10. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide 2. Jenkins polling
  11. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide 2. Jenkins polling 3. install gem by Gemfile (bundler)
  12. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide 2. Jenkins polling 3. install gem by Gemfile (bundler) 4. tar specific version directory and commit
  13. Using Jenkins to manage gem Overview Your machine Git repository

    Jenkins 1. commit Gemfile which you want to use system-wide 2. Jenkins polling 3. install gem by Gemfile (bundler) 4. tar specific version directory and commit 5. push tar ball
  14. Pros • less time to add new ruby version or

    install/upgrade gem than packaging rpm. • rbenv can share same environment over different many servers. • we can use and switchover some ruby versions • coexistence some ruby versions is difficult by using rpm ( rpm always overwrite new version ) • rbenv is developer friendly and simple • It is also easy for operation engineer, system administor
  15. Cons • `git clone` of puppet repository goes slow... •

    committing binary (tar ball of ruby) to git is not good manner maybe. • a little bit exaggerate approach ? • maybe “package” resource type of puppet also work well under rbenv environment. • I try to improve and make sure that Jenkins is needed or not.