SlideShare a Scribd company logo
1 of 51
Download to read offline
CRATE
Packaging Standalone Ruby Applications

         Jeremy Hinegardner

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

•beanstalkd    •amalgalite
•haproxy       •crate
•libtomcrypt   •keybox
•libtommath    •launchy
•nginx         •heel
•ragel         •hitimes
•tinyproxy     •htauth
               •rabal
               •stickler
Crate
   &
Amalgalite
SURVEY
PRE HISTORY
RubyConf 2007 (Charlotte, NC)
PRE HISTORY
              RubyConf 2007 (Charlotte, NC)



• Sploitin’ with   Ruby

  • Aaron   Bedra
PRE HISTORY
              RubyConf 2007 (Charlotte, NC)



• Sploitin’ with   Ruby

  • Aaron   Bedra

• Deploying   Ruby Runtimes

  • Bruce Williams   & Rich Kilmer
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?

• compiler?   - quite possibly not
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?
Crate - Packaging Standalone Ruby Applications
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

    Ruby                                     Application
          rubylib
 exe
                           Extension
       dlls
                                      gems
                           sitelib




                    application.exe
   eee.exe              eee.gz               trailer
Crate - Packaging Standalone Ruby Applications
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 capabilities

  • more    than linux, mac, windows, cygwin
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 based application
embedded Ruby
 C    + ruby extensions
      + main wrapper
      + standard library
Ruby + application code
   Crate based application
Statically Compile

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

       embedded Ruby
 C    + ruby extensions
      + main wrapper
      + standard library
Ruby + application code
   Crate based application


                       Amalgalite
Statically Compile

       embedded Ruby
 C    + ruby extensions
      + main wrapper
      + standard library
Ruby + application code
   Crate based application


           Pack into Amalgalite
1   CREATE TABLE rubylibs (
2         id            INTEGER PRIMARY KEY AUTOINCREMENT,
3         filename      TEXT UNIQUE,
4         compressed    BOOLEAN,
5         contents      BLOB
6         );
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
 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
Amalgalite ruby driver is
bootstrapped in its C extension
DEMO
BOOTSTRAPPING
ISSUE #1 - AUTOLOAD
ISSUE #1 - AUTOLOAD

• Problem

 • bypasses   the require chain setup by amalgalite

 • used   by rack, active_support, active_record
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?
ISSUE #2 - VIEWS IN WEB
     FRAMEWORKS
ISSUE #2 - VIEWS IN WEB
          FRAMEWORKS

• Problem

 • layout   and templates loaded from disk
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.
ISSUE #3 - CLASS RELOADING


• Problem

  • Development     mode reloads classes

• Solution   ( for now )

  • production   mode when running as crate based apps
ISSUE #4 - NOT WINDOWS
     FRIENDLY ( YET )
QUESTIONS?

More Related Content

Recently uploaded

Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 

Recently uploaded (20)

Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 

Crate - Packaging Standalone Ruby Applications

  • 1. CRATE Packaging Standalone Ruby Applications Jeremy Hinegardner jeremy@copiousfreetime.org @copiousfreetime
  • 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. Crate & Amalgalite
  • 5. PRE HISTORY RubyConf 2007 (Charlotte, NC)
  • 6. PRE HISTORY RubyConf 2007 (Charlotte, NC) • Sploitin’ with Ruby • Aaron Bedra
  • 7. PRE HISTORY RubyConf 2007 (Charlotte, NC) • Sploitin’ with Ruby • Aaron Bedra • Deploying Ruby Runtimes • Bruce Williams & Rich Kilmer
  • 11. NO CONTROL • interpreters? - perl probably, python maybe, ruby most likely not
  • 12. NO CONTROL • interpreters? - perl probably, python maybe, ruby most likely not • what libraries? - openssl? zlib?
  • 13. NO CONTROL • interpreters? - perl probably, python maybe, ruby most likely not • what libraries? - openssl? zlib? • compiler? - quite possibly not
  • 14. What do you do, when only thing you know about your deployment location, is the Operating System?
  • 15. AND YOU LOVE RUBY.
  • 17. SO WHAT IS CRATE?
  • 20. embedded Ruby + ruby extensions
  • 21. embedded Ruby + ruby extensions + main wrapper
  • 22. embedded Ruby + ruby extensions + main wrapper + standard library
  • 23. embedded Ruby + ruby extensions + main wrapper + standard library + application code
  • 24. embedded Ruby + ruby extensions + main wrapper + standard library + application code Crate based application
  • 26. http://www.erikveen.dds.nl/rubyscript2exe Ruby Application rubylib exe Extension dlls gems sitelib application.exe eee.exe eee.gz trailer
  • 29. MY NEEDS • Minimally Invasive • do not unpack to a temporary location • small as can be
  • 30. MY NEEDS • Minimally Invasive • do not unpack to a temporary location • small as can be • Wide deployment capabilities • more than linux, mac, windows, cygwin
  • 31. embedded Ruby + ruby extensions + main wrapper + standard library + application code Crate based application
  • 32. embedded Ruby C + ruby extensions + main wrapper + standard library + application code Crate based application
  • 33. embedded Ruby C + ruby extensions + main wrapper + standard library Ruby + application code Crate based application
  • 34. Statically Compile embedded Ruby C + ruby extensions + main wrapper + standard library Ruby + application code Crate based application
  • 35. Statically Compile embedded Ruby C + ruby extensions + main wrapper + standard library Ruby + application code Crate based application Amalgalite
  • 36. Statically Compile embedded Ruby C + ruby extensions + main wrapper + standard library Ruby + application code Crate based application Pack into Amalgalite
  • 37. 1 CREATE TABLE rubylibs ( 2       id            INTEGER PRIMARY KEY AUTOINCREMENT, 3       filename      TEXT UNIQUE, 4       compressed    BOOLEAN, 5       contents      BLOB 6       );
  • 38. 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
  • 39.  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
  • 40. Amalgalite ruby driver is bootstrapped in its C extension
  • 41. DEMO
  • 43. ISSUE #1 - AUTOLOAD
  • 44. ISSUE #1 - AUTOLOAD • Problem • bypasses the require chain setup by amalgalite • used by rack, active_support, active_record
  • 45. 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?
  • 46. ISSUE #2 - VIEWS IN WEB FRAMEWORKS
  • 47. ISSUE #2 - VIEWS IN WEB FRAMEWORKS • Problem • layout and templates loaded from disk
  • 48. 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.
  • 49. ISSUE #3 - CLASS RELOADING • Problem • Development mode reloads classes • Solution ( for now ) • production mode when running as crate based apps
  • 50. ISSUE #4 - NOT WINDOWS FRIENDLY ( YET )

Editor's Notes

  1. 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 ?
  2. Anyone, in the audience have any ideas?
  3. eee is an exractor written in pascal eee.gz is ruby + extensions + the application trailer at the end. mac, windows, linux, cygwin
  4. Shooes is pretty cool, and targeted towards gui based applications.
  5. I do not want to worry about cleaning up temporary files. I want to deployt to Solaris, AIX, HPUX, virtually anywhere ruby can run, I want crate to run.
  6. I do not want to worry about cleaning up temporary files. I want to deployt to Solaris, AIX, HPUX, virtually anywhere ruby can run, I want crate to run.
  7. Create a table to store all the ruby code from the standard library and gems
  8. Very similar to how rubygems works.
  9. 1. initialize the ruby interpreter 2. set ARGV for ruby 3. initialize all statically compiled extensions 4. bootstrap the Amalgalite driver 5. remove all filesystem directories from the $LOAD_PATH 6. switch to using Amalgalite backed require 7. require the file in the C constant CRATE_MAIN_FILE 8. instantiate a single instance of the class named in the C constant CRATE_MAIN_CLASS 9. invoke run( ARGV, ENV) on the newly instantiated class 10. exit
  10. 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,