CRATE
Ruby based, standalone executables

       Jeremy Hinegardner

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

•beanstalkd    •amalgalite
•haproxy       •crate
•libto...
Crate
   &
Amalgalite
SURVEY
PRE HISTORY
 RubyConf 2007
PRE HISTORY
                          RubyConf 2007



• Sploitin’ with   Ruby

  • Aaron   Bedra
PRE HISTORY
                          RubyConf 2007



• Sploitin’ with   Ruby

  • Aaron   Bedra

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


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


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

• what   libraries? - openssl? zlib?
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 target
system, is the Operating System?
AND YOU LOVE RUBY.
YOU MAKE CRATE.
SO WHAT IS CRATE?
embedded Ruby
embedded Ruby
+ ruby extensions
embedded Ruby
+ ruby extensions
+ main wrapper
embedded Ruby
+ ruby extensions
+ main wrapper
+ standard library
embedded Ruby
+ ruby extensions
+ main wrapper
+ standard library
+ application code
embedded Ruby
   + ruby extensions
   + main wrapper
   + standard library
   + application code
Crate based application
RUBYSCRIPT2EXE ?
http://www.erikveen.dds.nl/rubyscript2exe
SHOES ?
MY NEEDS
MY NEEDS

• Minimally   Invasive

  • do   not unpack to a temporary location

  • small   as can be
MY NEEDS

• Minimally   Invasive

  • do   not unpack to a temporary location

  • small   as can be

• Wide   deployment ...
embedded Ruby
   + ruby extensions
   + main wrapper
   + standard library
   + application code
Crate based application
embedded Ruby
C      + ruby extensions
       + main wrapper
       + standard library
       + application code
    Crate...
embedded Ruby
 C    + ruby extensions
      + main wrapper
      + standard library
Ruby + application code
   Crate based...
Statically Compile

       embedded Ruby
 C    + ruby extensions
      + main wrapper
      + standard library
Ruby + appl...
Statically Compile

       embedded Ruby
 C    + ruby extensions
      + main wrapper
      + standard library
Ruby + appl...
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
ISSUE #1 - AUTOLOAD
ISSUE #1 - AUTOLOAD

• Problem

 • bypasses   the require chain setup by amalgalite

 • used   by rack, active_support, ac...
ISSUE #1 - AUTOLOAD

• Problem

  • bypasses   the require chain setup by amalgalite

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

• Problem

 • layout   and templates loaded from disk
ISSUE #2 - VIEWS

• Problem

  • layout   and templates loaded from disk

• Solution

  • wait   for Rails 3

  • sinatra,...
ISSUE #3 - CLASS RELOADING


• Problem

  • Development     mode reloads classes

• Solution   ( for now )

  • production...
QUESTIONS?
Crate - ruby based standalone executables
Upcoming SlideShare
Loading in...5
×

Crate - ruby based standalone executables

2,528

Published on

This is the version of my Crate talk that was given at Scotland on Rails 2009.

This talk will cover the Crate project and how it may be used to package your web application. The end result is a statically built executable of the ruby interpreter and all dependent binary extensions. The application code, ruby stdlib the web framework itself, and all assets are packed into one or more SQLite databases.

Published in: Technology, Education
1 Comment
0 Likes
Statistics
Notes
  • Thanks for posting your slides. But how do I view it after I unzipped your zip-file?
    Please explain.
    What is the original file type? How did you ctrate the zip file?

    Thanks

    BlazingCyber@yahoo.com
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total Views
2,528
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
24
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide



  • How many of you have full control over your application deployment?
    How many of your know how many instance of your application there will be?
    Desktop applications?
    IT Shops? distribute small apps to your company for command / control monitoring ?































  • Very similar to how rubygems works.







  • I left out a fair bit of nitty gritty details
    would you like me to expand on anything, show some more code, yell and scream at me,
  • Crate - ruby based standalone executables

    1. 1. CRATE Ruby based, standalone executables 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
    6. 6. PRE HISTORY RubyConf 2007 • Sploitin’ with Ruby • Aaron Bedra
    7. 7. PRE HISTORY RubyConf 2007 • Sploitin’ with Ruby • Aaron Bedra • Deploying Ruby Runtimes • Bruce Williams & Rich Kilmer
    8. 8. STORYTIME
    9. 9. PERL 4, 1993
    10. 10. NO CONTROL
    11. 11. NO CONTROL • interpreters? - perl probably, python maybe, ruby most likely not
    12. 12. NO CONTROL • interpreters? - perl probably, python maybe, ruby most likely not • what libraries? - openssl? zlib?
    13. 13. NO CONTROL • interpreters? - perl probably, python maybe, ruby most likely not • what libraries? - openssl? zlib? • compiler? - quite possibly not
    14. 14. What do you do, when only thing you know about your target system, is the Operating System?
    15. 15. AND YOU LOVE RUBY.
    16. 16. YOU MAKE CRATE.
    17. 17. SO WHAT IS CRATE?
    18. 18. embedded Ruby
    19. 19. embedded Ruby + ruby extensions
    20. 20. embedded Ruby + ruby extensions + main wrapper
    21. 21. embedded Ruby + ruby extensions + main wrapper + standard library
    22. 22. embedded Ruby + ruby extensions + main wrapper + standard library + application code
    23. 23. embedded Ruby + ruby extensions + main wrapper + standard library + application code Crate based application
    24. 24. RUBYSCRIPT2EXE ?
    25. 25. http://www.erikveen.dds.nl/rubyscript2exe
    26. 26. SHOES ?
    27. 27. MY NEEDS
    28. 28. MY NEEDS • Minimally Invasive • do not unpack to a temporary location • small as can be
    29. 29. MY NEEDS • Minimally Invasive • do not unpack to a temporary location • small as can be • Wide deployment capabilities • more than linux, mac, windows, cygwin
    30. 30. embedded Ruby + ruby extensions + main wrapper + standard library + application code Crate based application
    31. 31. embedded Ruby C + ruby extensions + main wrapper + standard library + application code Crate based application
    32. 32. embedded Ruby C + ruby extensions + main wrapper + standard library Ruby + application code Crate based application
    33. 33. Statically Compile embedded Ruby C + ruby extensions + main wrapper + standard library Ruby + application code Crate based application
    34. 34. Statically Compile embedded Ruby C + ruby extensions + main wrapper + standard library Ruby + application code Crate based application Amalgalite
    35. 35. Statically Compile embedded Ruby C + ruby extensions + main wrapper + standard library Ruby + application code Crate based application Pack into Amalgalite
    36. 36. 1 CREATE TABLE rubylibs ( 2       id            INTEGER PRIMARY KEY AUTOINCREMENT, 3       filename      TEXT UNIQUE, 4       compressed    BOOLEAN, 5       contents      BLOB 6       );
    37. 37. 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
    38. 38.  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
    39. 39. Amalgalite ruby driver is bootstrapped in its C extension
    40. 40. DEMO
    41. 41. ISSUE #1 - AUTOLOAD
    42. 42. ISSUE #1 - AUTOLOAD • Problem • bypasses the require chain setup by amalgalite • used by rack, active_support, active_record
    43. 43. 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?
    44. 44. ISSUE #2 - VIEWS
    45. 45. ISSUE #2 - VIEWS • Problem • layout and templates loaded from disk
    46. 46. ISSUE #2 - VIEWS • Problem • layout and templates loaded from disk • Solution • wait for Rails 3 • sinatra, others, make patches for upstream, if needed.
    47. 47. ISSUE #3 - CLASS RELOADING • Problem • Development mode reloads classes • Solution ( for now ) • production mode when running as crate based apps
    48. 48. QUESTIONS?
    1. A particular slide catching your eye?

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

    ×