CRATE
Packaging Standalone Ruby Applications

         Jeremy Hinegardner

     jeremy@copiousfreetime.org
          @copi...
COPIOUS FREE TIME
  Fedora           Ruby
 Packaging         Gems

•beanstalkd    •amalgalite
•haproxy       •crate
•libto...
Crate
   &
Amalgalite
SURVEY
PRE HISTORY
              RubyConf 2007 (Charlotte, NC)



• Sploitin’ with   Ruby

  • Aaron   Bedra

• Deploying   Ruby ...
STORYTIME
PERL 4, 1993
NO CONTROL


• interpreters?   - perl probably, python maybe, ruby most likely
 not

• what   libraries? - openssl? zlib?
...
What do you do, when only thing
    you know about your
  deployment location, is the
      Operating System?
AND YOU LOVE RUBY.
YOU MAKE CRATE.
SO WHAT IS CRATE?
embedded Ruby
   + ruby extensions
   + main wrapper
   + standard library
   + application code
Crate based application
RUBYSCRIPT2EXE ?
http://www.erikveen.dds.nl/rubyscript2exe

    Ruby                                     Application
          rubylib
 exe...
MY NEEDS

• Minimally   Invasive

  • do   not unpack to a temporary location

  • small   as can be

• Wide   deployment ...
Statically Compile

       embedded Ruby
 C    + ruby extensions
      + main wrapper
      + standard library
Ruby + appl...
1   CREATE TABLE rubylibs (
2         id            INTEGER PRIMARY KEY AUTOINCREMENT,
3         filename      TEXT UNIQUE...
Inexact Size Measurements

                   Executable + C
                                    Ruby libs
               ...
 1   module Kernel
 2     # alias the original require away to use later
 3     alias :amalgalite_original_require :requir...
Amalgalite ruby driver is
bootstrapped in its C extension
DEMO
BOOTSTRAPPING
ISSUE #1 - AUTOLOAD

• Problem

  • bypasses   the require chain setup by amalgalite

  • used   by rack, active_support, ...
ISSUE #2 - VIEWS IN WEB
           FRAMEWORKS

• Problem

  • layout   and templates loaded from disk

• Solution

  • wai...
ISSUE #3 - CLASS RELOADING


• Problem

  • Development     mode reloads classes

• Solution   ( for now )

  • production...
ISSUE #4 - NOT WINDOWS
     FRIENDLY ( YET )
QUESTIONS?
Crate  Packaging Standalone Ruby Applications
Upcoming SlideShare
Loading in...5
×

Crate Packaging Standalone Ruby Applications

1,652

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,652
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
34
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Crate Packaging Standalone Ruby Applications

  1. 1. CRATE Packaging Standalone Ruby Applications Jeremy Hinegardner jeremy@copiousfreetime.org @copiousfreetime
  2. 2. COPIOUS FREE TIME Fedora Ruby Packaging Gems •beanstalkd •amalgalite •haproxy •crate •libtomcrypt •keybox •libtommath •launchy •nginx •heel •ragel •hitimes •tinyproxy •htauth •rabal •stickler
  3. 3. Crate & Amalgalite
  4. 4. SURVEY
  5. 5. PRE HISTORY RubyConf 2007 (Charlotte, NC) • Sploitin’ with Ruby • Aaron Bedra • Deploying Ruby Runtimes • Bruce Williams & Rich Kilmer
  6. 6. STORYTIME
  7. 7. PERL 4, 1993
  8. 8. NO CONTROL • interpreters? - perl probably, python maybe, ruby most likely not • what libraries? - openssl? zlib? • compiler? - quite possibly not
  9. 9. What do you do, when only thing you know about your deployment location, is the Operating System?
  10. 10. AND YOU LOVE RUBY.
  11. 11. YOU MAKE CRATE.
  12. 12. SO WHAT IS CRATE?
  13. 13. embedded Ruby + ruby extensions + main wrapper + standard library + application code Crate based application
  14. 14. RUBYSCRIPT2EXE ?
  15. 15. http://www.erikveen.dds.nl/rubyscript2exe Ruby Application rubylib exe Extension dlls gems sitelib application.exe eee.exe eee.gz trailer
  16. 16. MY NEEDS • Minimally Invasive • do not unpack to a temporary location • small as can be • Wide deployment capabilities • more than linux, mac, windows, cygwin
  17. 17. Statically Compile embedded Ruby C + ruby extensions + main wrapper + standard library Ruby + application code Crate based application Pack into Amalgalite
  18. 18. 1 CREATE TABLE rubylibs ( 2       id            INTEGER PRIMARY KEY AUTOINCREMENT, 3       filename      TEXT UNIQUE, 4       compressed    BOOLEAN, 5       contents      BLOB 6       );
  19. 19. Inexact Size Measurements Executable + C Ruby libs extensions Ruby 1.8.6 2.4 M 8.4 M Crate/ruby 1.8.6 2.9 M 1.9 M
  20. 20.  1 module Kernel  2   # alias the original require away to use later  3   alias :amalgalite_original_require :require  4  5   #  6   # hook into the system 'require' to allow for required text or blobs from an  7   # amalgalite database.    8   #  9   def require( filename ) 10     loaded = amalgalite_original_require( filename ) 11   rescue LoadError => load_error 12     if load_error.message =~ /#{Regexp.escape filename}z/ then 13       loaded = Amalgalite::Requires.require( filename ) 14     else 15       raise load_error 16     end 17   end 18 19   private :require 20   private :amalgalite_original_require 21 end
  21. 21. Amalgalite ruby driver is bootstrapped in its C extension
  22. 22. DEMO
  23. 23. BOOTSTRAPPING
  24. 24. ISSUE #1 - AUTOLOAD • Problem • bypasses the require chain setup by amalgalite • used by rack, active_support, active_record • Solution • Port tree style patches? • custom gem builds?
  25. 25. ISSUE #2 - VIEWS IN WEB FRAMEWORKS • Problem • layout and templates loaded from disk • Solution • wait for Rails 3 • sinatra, others, make patches for upstream, if needed.
  26. 26. ISSUE #3 - CLASS RELOADING • Problem • Development mode reloads classes • Solution ( for now ) • production mode when running as crate based apps
  27. 27. ISSUE #4 - NOT WINDOWS FRIENDLY ( YET )
  28. 28. QUESTIONS?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×