SlideShare a Scribd company logo
.




.




             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

TXT
Udp scriptstart
PDF
Fizz and buzz of computer programs in python.
PDF
C: A Humbling Language
KEY
Gevent what's the point
PDF
IJTC%202009%20JRuby
PPT
How PHP Works ?
PPTX
Build a compiler in 2hrs - NCrafts Paris 2015
PDF
Learning Python from Data
Udp scriptstart
Fizz and buzz of computer programs in python.
C: A Humbling Language
Gevent what's the point
IJTC%202009%20JRuby
How PHP Works ?
Build a compiler in 2hrs - NCrafts Paris 2015
Learning Python from Data

Viewers also liked (7)

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

Similar to Raemon (20)

PDF
Advanced task management with Celery
PDF
Fluentd in Co-Work
PDF
Gearman and Perl
PDF
Workflow Yapceu2010
PDF
Gearman - Northeast PHP 2012
PDF
O que tem de novo no Ruby 2.0?
PDF
淺談Ruby process fork應用
ODP
Introduction to Python Celery
PDF
Celery with python
KEY
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
PDF
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
PDF
FireWorks workflow software
PPTX
Qless
PDF
Ruby talk romania
PDF
[Node] Multiprocessing and runs continuously
KEY
Asynchronous Awesome
PDF
Session11 Ucc Intro
PPT
High Performance Computing - Cloud Point of View
PDF
Rocket Fuelled Cucumbers
KEY
Polyglot parallelism
Advanced task management with Celery
Fluentd in Co-Work
Gearman and Perl
Workflow Yapceu2010
Gearman - Northeast PHP 2012
O que tem de novo no Ruby 2.0?
淺談Ruby process fork應用
Introduction to Python Celery
Celery with python
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
FireWorks workflow software
Qless
Ruby talk romania
[Node] Multiprocessing and runs continuously
Asynchronous Awesome
Session11 Ucc Intro
High Performance Computing - Cloud Point of View
Rocket Fuelled Cucumbers
Polyglot parallelism
Ad

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Hybrid model detection and classification of lung cancer
PDF
project resource management chapter-09.pdf
PPTX
A Presentation on Artificial Intelligence
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
1. Introduction to Computer Programming.pptx
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
August Patch Tuesday
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Heart disease approach using modified random forest and particle swarm optimi...
Web App vs Mobile App What Should You Build First.pdf
A comparative study of natural language inference in Swahili using monolingua...
Hybrid model detection and classification of lung cancer
project resource management chapter-09.pdf
A Presentation on Artificial Intelligence
Programs and apps: productivity, graphics, security and other tools
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
DP Operators-handbook-extract for the Mautical Institute
A novel scalable deep ensemble learning framework for big data classification...
1. Introduction to Computer Programming.pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Unlocking AI with Model Context Protocol (MCP)
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
August Patch Tuesday

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