SlideShare a Scribd company logo
1 of 8
Download to read offline
.




.




             Raemon
               @yinhm

               June 7, 2010




    .                 .
    @yinhm   Raemon           1/8
.




             Daemon libs
.




             • daemons
             • servolux
             • daemon kit




    .                                .
    @yinhm                  Raemon       2/8
.




             Raemon
.




             • base on unicorn
             • master -> multi-work(preforked) model




    .                                     .
    @yinhm                       Raemon                3/8
.




             Unicorn
.




             • it is UNIX
             • fork
             • IO::pipe, selfpipe
             • socket
             • tmpio




    .                                        .
    @yinhm                          Raemon       4/8
.




             example: consume queue
.
             #!/ u s r / b i n / env ruby
             r e q u i r e ' rubygems '
             r e q u i r e ' raemon '
             r e q u i r e ' b e a n s t a l k−c l i e n t '

             ENV[ " RAILS_ENV " ] ||= " development "
             r e q u i r e F i l e . dirname (__FILE__) + " / . . / . . / c o n f i g / environment "
             A c t i o n C o n t r o l l e r : : Base . perform_caching = f a l s e

             c l a s s FooJobWorker
                 TIMEOUT = 10
                 i n c l u d e Raemon : : Worker
                 def before_start
                     @ b e a n s t a l k = B e a n s t a l k : : Pool . new ( [ ' l o c a l h o s t : 1 1 3 0 0 ' ] , ' foo ' )
                 end
                 d e f before_shutdown
                     @beanstalk . c l o s e
                 end
                 def execute
                     ...
                 end
             end
             Raemon : : Master . s t a r t u p ( 2 , FooJobWorker , {
                                                           : detach          = true ,
                                                                              >
                                                           : logger          = Logger . new (RAILS_ROOT + '/ l o g / foo_queue . log ' ) ,
                                                                              >
                                                           : p i d _ f i l e = RAILS_ROOT + '/tmp/ p i d s / foo_queue . pid ' ,
                                                                              >
                                                           : timeout = 120    >
                                                       }). join
    .                                                                        .
    @yinhm                                                     Raemon                                                                        5/8
.




             example: execute
.
             c l a s s FooJobWorker
                 ...

                def execute
                  begin
                    j o b = @ b e a n s t a l k . r e s e r v e (TIMEOUT)

                      i f job
                         l o g g e r . i n f o "(#{ P r o c e s s . pp id }:#{ P r o c e s s . p i d }) got j o b : #{j o b . i n s p e c t }"

                           A c t i v e R e c o r d : : Base . c o n n e c t i o n . uncached do
                               f o o = Foo . f i n d ( j o b . ybody )
                               i f foo . process
                                   job . d e l e t e
                               else
                                   j o b . r e l e a s e ( j o b . p r i , 60)
                               end
                           end
                       end
                   r e s c u e B e a n s t a l k : : TimedOut
                   rescue StandardError
                       l o g g e r . e r r o r " Got e x c e p t i o n : #{$ ! . i n s p e c t }"

                   i f job
                      job . d e l e t e
                      job = n i l
                   end
                 end
    .          end
    @yinhm   end                                                      Raemon           .                                                         6/8
.




             References
.




             • Raemon
             • Unicorn
             • I like Unicorn because it's Unix




    .                                       .
    @yinhm                         Raemon         7/8
.




             About
.




                     Created in A E using the beamer class, TeX Live and Emacs.
                                L X
                                 T


                     Published under the Creative Commons Attribution 3.0 License
                           http://creativecommons.org/licenses/by/3.0/

                                             by @yinhm
                                     http://yinhm.appspot.com


                                   Document version June 7, 2010




    .                                              .
    @yinhm                             Raemon                                       8/8

More Related Content

Viewers also liked (7)

Dart intro
Dart introDart intro
Dart intro
 
Portafolio de servicios Enlaces Asesoria Empresarial en Recursos Humanos
Portafolio de servicios Enlaces Asesoria Empresarial en Recursos HumanosPortafolio de servicios Enlaces Asesoria Empresarial en Recursos Humanos
Portafolio de servicios Enlaces Asesoria Empresarial en Recursos Humanos
 
git svn workflow
git svn workflowgit svn workflow
git svn workflow
 
Write a Google Closure Editor Plugin
Write a Google Closure Editor PluginWrite a Google Closure Editor Plugin
Write a Google Closure Editor Plugin
 
Ruby的类和对象模型
Ruby的类和对象模型Ruby的类和对象模型
Ruby的类和对象模型
 
Emacs入门
Emacs入门Emacs入门
Emacs入门
 
Heroku
HerokuHeroku
Heroku
 

Similar to Raemon

Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
tobiascrawley
 
How to discover the Ruby's defects with web application
How to discover the Ruby's defects with web applicationHow to discover the Ruby's defects with web application
How to discover the Ruby's defects with web application
Hiroshi SHIBATA
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
旻琦 潘
 
Integrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby AmfIntegrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby Amf
railsconf
 
File & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxFile & Exception Handling in C++.pptx
File & Exception Handling in C++.pptx
RutujaTandalwade
 

Similar to Raemon (20)

Having Fun Programming!
Having Fun Programming!Having Fun Programming!
Having Fun Programming!
 
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
 
儲かるドキュメント
儲かるドキュメント儲かるドキュメント
儲かるドキュメント
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of Go
 
Fluent Development with FLOW3 1.0
Fluent Development with FLOW3 1.0Fluent Development with FLOW3 1.0
Fluent Development with FLOW3 1.0
 
Stop Reinventing The Wheel - The Ruby Standard Library
Stop Reinventing The Wheel - The Ruby Standard LibraryStop Reinventing The Wheel - The Ruby Standard Library
Stop Reinventing The Wheel - The Ruby Standard Library
 
How to discover the Ruby's defects with web application
How to discover the Ruby's defects with web applicationHow to discover the Ruby's defects with web application
How to discover the Ruby's defects with web application
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
Active Support Core Extensions (1)
Active Support Core Extensions (1)Active Support Core Extensions (1)
Active Support Core Extensions (1)
 
Unit-4 PPTs.pptx
Unit-4 PPTs.pptxUnit-4 PPTs.pptx
Unit-4 PPTs.pptx
 
Integrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby AmfIntegrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby Amf
 
Flex With Rubyamf
Flex With RubyamfFlex With Rubyamf
Flex With Rubyamf
 
Git::Hooks
Git::HooksGit::Hooks
Git::Hooks
 
Introduction to c part 4
Introduction to c  part  4Introduction to c  part  4
Introduction to c part 4
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To Batch
 
File & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxFile & Exception Handling in C++.pptx
File & Exception Handling in C++.pptx
 
Symfony 4 & Flex news
Symfony 4 & Flex newsSymfony 4 & Flex news
Symfony 4 & Flex news
 
earthquake.gem
earthquake.gemearthquake.gem
earthquake.gem
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 

Raemon

  • 1. . . Raemon @yinhm June 7, 2010 . . @yinhm Raemon 1/8
  • 2. . Daemon libs . • daemons • servolux • daemon kit . . @yinhm Raemon 2/8
  • 3. . Raemon . • base on unicorn • master -> multi-work(preforked) model . . @yinhm Raemon 3/8
  • 4. . Unicorn . • it is UNIX • fork • IO::pipe, selfpipe • socket • tmpio . . @yinhm Raemon 4/8
  • 5. . example: consume queue . #!/ u s r / b i n / env ruby r e q u i r e ' rubygems ' r e q u i r e ' raemon ' r e q u i r e ' b e a n s t a l k−c l i e n t ' ENV[ " RAILS_ENV " ] ||= " development " r e q u i r e F i l e . dirname (__FILE__) + " / . . / . . / c o n f i g / environment " A c t i o n C o n t r o l l e r : : Base . perform_caching = f a l s e c l a s s FooJobWorker TIMEOUT = 10 i n c l u d e Raemon : : Worker def before_start @ b e a n s t a l k = B e a n s t a l k : : Pool . new ( [ ' l o c a l h o s t : 1 1 3 0 0 ' ] , ' foo ' ) end d e f before_shutdown @beanstalk . c l o s e end def execute ... end end Raemon : : Master . s t a r t u p ( 2 , FooJobWorker , { : detach = true , > : logger = Logger . new (RAILS_ROOT + '/ l o g / foo_queue . log ' ) , > : p i d _ f i l e = RAILS_ROOT + '/tmp/ p i d s / foo_queue . pid ' , > : timeout = 120 > }). join . . @yinhm Raemon 5/8
  • 6. . example: execute . c l a s s FooJobWorker ... def execute begin j o b = @ b e a n s t a l k . r e s e r v e (TIMEOUT) i f job l o g g e r . i n f o "(#{ P r o c e s s . pp id }:#{ P r o c e s s . p i d }) got j o b : #{j o b . i n s p e c t }" A c t i v e R e c o r d : : Base . c o n n e c t i o n . uncached do f o o = Foo . f i n d ( j o b . ybody ) i f foo . process job . d e l e t e else j o b . r e l e a s e ( j o b . p r i , 60) end end end r e s c u e B e a n s t a l k : : TimedOut rescue StandardError l o g g e r . e r r o r " Got e x c e p t i o n : #{$ ! . i n s p e c t }" i f job job . d e l e t e job = n i l end end . end @yinhm end Raemon . 6/8
  • 7. . References . • Raemon • Unicorn • I like Unicorn because it's Unix . . @yinhm Raemon 7/8
  • 8. . About . Created in A E using the beamer class, TeX Live and Emacs. L X T Published under the Creative Commons Attribution 3.0 License http://creativecommons.org/licenses/by/3.0/ by @yinhm http://yinhm.appspot.com Document version June 7, 2010 . . @yinhm Raemon 8/8