SlideShare ist ein Scribd-Unternehmen logo
1 von 39
COUNTING ON GOD
      Can we?
GOD’S CHILDREN
ELEMENTS OF
MONITORED PROCESSES
ELEMENTS OF
        MONITORED PROCESSES


• PID   files
ELEMENTS OF
        MONITORED PROCESSES


• PID   files

• Long   running nature (decoupled start/stop)
ELEMENTS OF
        MONITORED PROCESSES


• PID   files

• Long   running nature (decoupled start/stop)

• Daemonization
PID FILES
PID FILE BASICS
module PIDFile
  module_function

  def create(path)
    open(path, File::CREAT | File::EXCL | File::WRONLY) do |pid|
      pid.flock(File::LOCK_EX)
      pid.puts Process.pid
      pid.flock(File::LOCK_UN)
    end

   at_exit do
     remove(path)
   end

    true
  rescue Errno::EEXIST   # file already exists
    false
  end

  def remove(path)
    File.unlink(path)
    true
  rescue Exception
    false
  end
end
PID FILES IN ACTION
require "pid_file"

if PIDFile.create("show_pid.pid")
  puts "Running as #{Process.pid}..."
  sleep 10
  puts "Shutting down."
else
  puts "Already running."
end
PID FILES IN ACTION
require "pid_file"

if PIDFile.create("show_pid.pid")
  puts "Running as #{Process.pid}..."
  sleep 10
  puts "Shutting down."
else
  puts "Already running."
end
                       $ ruby -I . show_pid.rb
                       Running as 3756...
                       Shutting down.
PID FILES IN ACTION
require "pid_file"

if PIDFile.create("show_pid.pid")
  puts "Running as #{Process.pid}..."
  sleep 10
  puts "Shutting down."
else
  puts "Already running."
end
                       $ ruby -I . show_pid.rb
                       Running as 3756...
                       Shutting down.
                                       $ cat show_pid.pid
                                       cat: show_pid.pid: No such file or directory
                                       $ ruby -I . show_pid.rb
                                       Already running.
                                       $ cat show_pid.pid
                                       3756
                                       $ cat show_pid.pid
                                       cat: show_pid.pid: No such file or directory
LONG RUNNING NATURE
LONG RUNNING PROCESSES
    require "pid_file"

    module LongRunningProcess
      module_function

      def manage(name, args = ARGV, &job)
        pid_path = "/Users/james/Desktop/#{name}.pid"
        if args.include? "stop"
          if pid = File.read(pid_path).to_i rescue nil
             Process.kill("TERM", pid)
          else
            puts "Not running."
          end
        else
          if PIDFile.create(pid_path)
            job.call
          else
            puts "Already running."
          end
        end
      end
    end
LONG RUNNING PROCESSES
      IN ACTION
require "long_running_process"

LongRunningProcess.manage("show_long_running_process") do
  puts "Running as #{Process.pid}..."
  at_exit do
    puts "Shutting down."
  end
  loop do
    sleep
  end
end
LONG RUNNING PROCESSES
      IN ACTION
require "long_running_process"

LongRunningProcess.manage("show_long_running_process") do
  puts "Running as #{Process.pid}..."
  at_exit do
    puts "Shutting down."
  end
  loop do
    sleep
  end        $ ruby -I . show_long_running_process.rb start
end          Running as 6970...
            Shutting down.
            Terminated
LONG RUNNING PROCESSES
      IN ACTION
require "long_running_process"

LongRunningProcess.manage("show_long_running_process") do
  puts "Running as #{Process.pid}..."
  at_exit do
    puts "Shutting down."
  end
  loop do
    sleep
  end        $ ruby -I . show_long_running_process.rb start
end          Running as 6970...
            Shutting down.
            Terminated
                         $ cat show_long_running_process.pid
                         cat: show_long_running_process.pid: No such file or directory
                         $ cat show_long_running_process.pid
                         6970
                         $ ruby -I . show_long_running_process.rb start
                         Already running.
                         $ ruby -I . show_long_running_process.rb stop
                         $ cat show_long_running_process.pid
                         cat: show_long_running_process.pid: No such file or directory
DAEMONS
SUPPORTING
 DAEMONIZATION
def create(path, &daemonize)
  open(path, File::CREAT | File::EXCL | File::WRONLY) do |pid|
    pid.flock(File::LOCK_EX)
    begin
      if daemonize.nil? or (daemonize.call rescue false)
        pid.puts Process.pid
      else
        return false
      end
    ensure
      pid.flock(File::LOCK_UN)
    end
  end

 at_exit do
   remove(path)
 end

  true
rescue Errno::EEXIST   # file already exists
  false
end
DAEMONIZING


if PIDFile.create(pid_path) { Process.daemon }
A MINOR GOD
THE SMALLEST POSSIBLE GOD

  DESKTOP = "/Users/james/Desktop"
  RUBY    = "ruby -I #{DESKTOP}"

  God.watch do |w|
    w.name            =   "show_long_running_process"
    w.interval        =   30.seconds
    w.start           =   "#{RUBY} #{DESKTOP}/show_long_running_process.rb start"
    w.stop            =   "#{RUBY} #{DESKTOP}/show_long_running_process.rb stop"
    w.start_grace     =   10.seconds
    w.restart_grace   =   10.seconds
    w.pid_file        =   "#{DESKTOP}/show_long_running_process.pid"

    w.start_if do |start|
      start.condition(:process_running) do |c|
        c.interval = 5.seconds
        c.running = false
      end
    end
  end
IN ACTION
$ rvm 1.9.2
$ rvmsudo god -c minor_god.god -D
I [2011-01-13 15:42:43] INFO: Loading minor_god.god
I [2011-01-13 15:42:43] INFO: Syslog enabled.
I [2011-01-13 15:42:43] INFO: Using pid file directory: /var/run/god
I [2011-01-13 15:42:43] INFO: Started on drbunix:///tmp/god.17165.sock
I [2011-01-13 15:42:43] INFO: show_long_running_process move 'unmonitored' to 'up'
I [2011-01-13 15:42:43] INFO: show_long_running_process moved 'unmonitored' to 'up'
I [2011-01-13 15:42:43] INFO: show_long_running_process [trigger] process is not running
(ProcessRunning)
I [2011-01-13 15:42:43] INFO: show_long_running_process move 'up' to 'start'
I [2011-01-13 15:42:43] INFO: show_long_running_process start: ruby -I /Users/james/Desktop /
Users/james/Desktop/show_long_running_process.rb start
I [2011-01-13 15:42:53] INFO: show_long_running_process moved 'up' to 'up'
I [2011-01-13 15:42:53] INFO: show_long_running_process [ok] process is running
(ProcessRunning)
I [2011-01-13 15:42:58] INFO: show_long_running_process [ok] process is running
(ProcessRunning)
I [2011-01-13 15:43:03] INFO: show_long_running_process [ok] process is running
(ProcessRunning)
I [2011-01-13 15:43:09] INFO: show_long_running_process [ok] process is running
(ProcessRunning)
^C/Users/james/.rvm/gems/ruby-1.9.2-p136/gems/god-0.11.0/lib/god.rb:656:in `join': Interrupt
  from /Users/james/.rvm/gems/ruby-1.9.2-p136/gems/god-0.11.0/lib/god.rb:656:in `start'
  from /Users/james/.rvm/gems/ruby-1.9.2-p136/gems/god-0.11.0/lib/god.rb:667:in `at_exit'
  from /Users/james/.rvm/gems/ruby-1.9.2-p136/gems/god-0.11.0/lib/god.rb:700:in `block in <top
(required)>'
DOING EVIL
      UNDER GOD’S GAZE
$ rvmsudo god -c minor_god.god
$ ps auxww | grep show_long_running_process
root      1986   0.2 0.0 2448168      952   ?? S      3:56PM   0:00.02 ruby -
I /Users/james/Desktop /Users/james/Desktop/show_long_running_process.rb start
james     1988   0.0 0.0 2435116      532 s000 S+     3:57PM   0:00.00 grep
show_long_running_process
$ sudo kill 1986
$ ps auxww | grep show_long_running_process
root      1996   0.2 0.0 2448168      936   ?? S      3:57PM   0:00.00 ruby -
I /Users/james/Desktop /Users/james/Desktop/show_long_running_process.rb start
james     1998   0.0 0.0 2435116      532 s000 S+     3:57PM   0:00.00 grep
show_long_running_process
$ rvmsudo god terminate
..
Stopped all watches
Stopped god
$ ps auxww | grep show_long_running_process
james     2005   0.0 0.0 2435116      532 s000 S+     3:57PM   0:00.00 grep
show_long_running_process
COMPLICATIONS OF GOD
CLEANING PID FILES


     w.behavior(:clean_pid_file)
CONDITIONAL RESTARTS

    w.restart_if do |restart|
      restart.condition(:memory_usage) do |c|
        c.above = 150.megabytes
        c.times = [3, 5] # 3 out of 5 intervals
      end

      restart.condition(:cpu_usage) do |c|
        c.above = 50.percent
        c.times = 5
      end
    end
CONTROLLING DEATH

    w.lifecycle do |on|
      on.condition(:flapping) do |c|
        c.to_state = [:start, :restart]
        c.times = 5
        c.within = 5.minute
        c.transition = :unmonitored
        c.retry_in = 10.minutes
        c.retry_times = 5
        c.retry_within = 2.hours
      end
    end
THE POWER OF GOD
# determine the state on startup
w.transition(:init, { true => :up, false => :start }) do |on|
  on.condition(:process_running) do |c|
    c.running = true
  end
end

# determine when process has finished starting
w.transition([:start, :restart], :up) do |on|
  on.condition(:process_running) do |c|          # start if process is not running
    c.running = true                             w.transition(:up, :start) do |on|
  end                                              on.condition(:process_exits)
                                                 end
  # failsafe
  on.condition(:tries) do |c|                    # restart if memory or cpu is too high
    c.times = 5                                  w.transition(:up, :restart) do |on|
    c.transition = :start                          on.condition(:memory_usage) do |c|
  end                                                c.interval = 20
end                                                  c.above = 50.megabytes
                                                     c.times = [3, 5]
                                                   end

                                                   on.condition(:cpu_usage) do |c|
                                                     c.interval = 10
                                                     c.above = 10.percent
                                                     c.times = [3, 5]
                                                   end
                                                 end
WEIGHING AND
MEASURING GOD
HOW BIG IS GOD?

$ ps -p 2177 -o pid,%mem,rss,command
  PID %MEM    RSS COMMAND
 2177 0.2 16624 /Users/james/.rvm/rubies/ruby-1.9.2-p136/bin/ruby /Users/jame
$ ps -p 2184 -o pid,%mem,rss,command
  PID %MEM    RSS COMMAND
 2184 0.0     928 ruby -I /Users/james/Desktop /Users/james/Desktop/show_long_r
GOD’S JOY
GOD’S JOY


• Super   easy gem install and setup
GOD’S JOY


• Super    easy gem install and setup

• It   works on Ruby 1.9.2
GOD’S JOY


• Super    easy gem install and setup

• It   works on Ruby 1.9.2

• Ruby    DSL can be handy
GOD’S JOY


• Super    easy gem install and setup

• It   works on Ruby 1.9.2

• Ruby    DSL can be handy

• Very    configurable with lots of options
THE PRICE OF GOD
THE PRICE OF GOD


• Ruby   DSL isn’t at all natural
THE PRICE OF GOD


• Ruby   DSL isn’t at all natural

• God    process in moderately expensive
THE PRICE OF GOD


• Ruby   DSL isn’t at all natural

• God    process in moderately expensive

• God    leaked memory in the past (I think this is resolved now)

Weitere ähnliche Inhalte

Was ist angesagt?

Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0bcoca
 
Presentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugPresentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugSĂŠbastien Deleuze
 
Writing & Sharing Great Modules on the Puppet Forge
Writing & Sharing Great Modules on the Puppet ForgeWriting & Sharing Great Modules on the Puppet Forge
Writing & Sharing Great Modules on the Puppet ForgePuppet
 
Beyond Page Level Metrics
Beyond Page Level MetricsBeyond Page Level Metrics
Beyond Page Level MetricsPhilip Tellis
 
Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011Puppet
 
Troubleshooting the Puppet Enterprise Stack
Troubleshooting the Puppet Enterprise StackTroubleshooting the Puppet Enterprise Stack
Troubleshooting the Puppet Enterprise StackPuppet
 
#SPUG - Legacy applications
#SPUG - Legacy applications#SPUG - Legacy applications
#SPUG - Legacy applicationsPiotr Pasich
 
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...Puppet
 
MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)MongoSF
 
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pmRyosuke IWANAGA
 
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...Puppet
 
Configuration Surgery with Augeas
Configuration Surgery with AugeasConfiguration Surgery with Augeas
Configuration Surgery with AugeasPuppet
 
Reactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/OReactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/OArawn Park
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linuxtutorialsruby
 
Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013grim_radical
 
Automated release management with team city & octopusdeploy - NDC 2013
Automated release management with team city & octopusdeploy - NDC 2013Automated release management with team city & octopusdeploy - NDC 2013
Automated release management with team city & octopusdeploy - NDC 2013Kristoffer Deinoff
 

Was ist angesagt? (19)

Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0
 
Presentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJugPresentation DVCS - Git - Mercurial au LyonJug
Presentation DVCS - Git - Mercurial au LyonJug
 
Writing & Sharing Great Modules on the Puppet Forge
Writing & Sharing Great Modules on the Puppet ForgeWriting & Sharing Great Modules on the Puppet Forge
Writing & Sharing Great Modules on the Puppet Forge
 
Beyond Page Level Metrics
Beyond Page Level MetricsBeyond Page Level Metrics
Beyond Page Level Metrics
 
Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Troubleshooting the Puppet Enterprise Stack
Troubleshooting the Puppet Enterprise StackTroubleshooting the Puppet Enterprise Stack
Troubleshooting the Puppet Enterprise Stack
 
Troubleshooting Puppet
Troubleshooting PuppetTroubleshooting Puppet
Troubleshooting Puppet
 
#SPUG - Legacy applications
#SPUG - Legacy applications#SPUG - Legacy applications
#SPUG - Legacy applications
 
File::CleanupTask
File::CleanupTaskFile::CleanupTask
File::CleanupTask
 
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
PuppetConf 2017: Use Puppet to Tame the Dockerfile Monster- Bryan Belanger, A...
 
MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)MongoDB Replication (Dwight Merriman)
MongoDB Replication (Dwight Merriman)
 
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
 
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...
 
Configuration Surgery with Augeas
Configuration Surgery with AugeasConfiguration Surgery with Augeas
Configuration Surgery with Augeas
 
Reactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/OReactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/O
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
 
Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013
 
Automated release management with team city & octopusdeploy - NDC 2013
Automated release management with team city & octopusdeploy - NDC 2013Automated release management with team city & octopusdeploy - NDC 2013
Automated release management with team city & octopusdeploy - NDC 2013
 

Andere mochten auch

Building a Rails Interface
Building a Rails InterfaceBuilding a Rails Interface
Building a Rails InterfaceJames Gray
 
A Dickens of A Keynote
A Dickens of A KeynoteA Dickens of A Keynote
A Dickens of A KeynoteJames Gray
 
I Doubt That!
I Doubt That!I Doubt That!
I Doubt That!James Gray
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsJames Gray
 
Techniques for Reviewing a User Interface
Techniques for Reviewing a User InterfaceTechniques for Reviewing a User Interface
Techniques for Reviewing a User InterfaceRhonda Bracey
 
The impact of spirituality before and after treatment of major depressive epi...
The impact of spirituality before and after treatment of major depressive epi...The impact of spirituality before and after treatment of major depressive epi...
The impact of spirituality before and after treatment of major depressive epi...Ignazio Graffeo CyberMaster
 
Does god exist
Does god existDoes god exist
Does god existEdz Gapuz
 
A 30 Second Argument For God
A 30 Second Argument For GodA 30 Second Argument For God
A 30 Second Argument For GodRobin Schumacher
 
Does God Exist?
Does God Exist?Does God Exist?
Does God Exist?Kyle Deming
 
Sikhism presentation
Sikhism presentationSikhism presentation
Sikhism presentationHarpreet Singh
 
Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Jargalsaikhan Alyeksandr
 

Andere mochten auch (11)

Building a Rails Interface
Building a Rails InterfaceBuilding a Rails Interface
Building a Rails Interface
 
A Dickens of A Keynote
A Dickens of A KeynoteA Dickens of A Keynote
A Dickens of A Keynote
 
I Doubt That!
I Doubt That!I Doubt That!
I Doubt That!
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Techniques for Reviewing a User Interface
Techniques for Reviewing a User InterfaceTechniques for Reviewing a User Interface
Techniques for Reviewing a User Interface
 
The impact of spirituality before and after treatment of major depressive epi...
The impact of spirituality before and after treatment of major depressive epi...The impact of spirituality before and after treatment of major depressive epi...
The impact of spirituality before and after treatment of major depressive epi...
 
Does god exist
Does god existDoes god exist
Does god exist
 
A 30 Second Argument For God
A 30 Second Argument For GodA 30 Second Argument For God
A 30 Second Argument For God
 
Does God Exist?
Does God Exist?Does God Exist?
Does God Exist?
 
Sikhism presentation
Sikhism presentationSikhism presentation
Sikhism presentation
 
Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)
 

Ähnlich wie Counting on God

God Presentation
God PresentationGod Presentation
God PresentationAmit Solanki
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Django Celery
Django Celery Django Celery
Django Celery Mat Clayton
 
What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017Quentin Adam
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Puppet
 
What is systemd? Why use it? how does it work? - breizhcamp
What is systemd? Why use it? how does it work? - breizhcampWhat is systemd? Why use it? how does it work? - breizhcamp
What is systemd? Why use it? how does it work? - breizhcampQuentin Adam
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingDan Morrill
 
Puppi. Puppet strings to the shell
Puppi. Puppet strings to the shellPuppi. Puppet strings to the shell
Puppi. Puppet strings to the shellAlessandro Franceschi
 
Large scale machine learning projects with R Suite
Large scale machine learning projects with R SuiteLarge scale machine learning projects with R Suite
Large scale machine learning projects with R SuiteWLOG Solutions
 
Large scale machine learning projects with r suite
Large scale machine learning projects with r suiteLarge scale machine learning projects with r suite
Large scale machine learning projects with r suiteWit Jakuczun
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkMichael Peacock
 
Puppet Camp 2012
Puppet Camp 2012Puppet Camp 2012
Puppet Camp 2012Server Density
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionIan Barber
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Composeraccoony
 
Practical Celery
Practical CeleryPractical Celery
Practical CeleryCameron Maske
 
Get Grulping with JavaScript Task Runners
Get Grulping with JavaScript Task RunnersGet Grulping with JavaScript Task Runners
Get Grulping with JavaScript Task RunnersMatt Gifford
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleStein Inge Morisbak
 

Ähnlich wie Counting on God (20)

God Presentation
God PresentationGod Presentation
God Presentation
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Django Celery
Django Celery Django Celery
Django Celery
 
What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
 
What is systemd? Why use it? how does it work? - breizhcamp
What is systemd? Why use it? how does it work? - breizhcampWhat is systemd? Why use it? how does it work? - breizhcamp
What is systemd? Why use it? how does it work? - breizhcamp
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
 
Puppi. Puppet strings to the shell
Puppi. Puppet strings to the shellPuppi. Puppet strings to the shell
Puppi. Puppet strings to the shell
 
Large scale machine learning projects with R Suite
Large scale machine learning projects with R SuiteLarge scale machine learning projects with R Suite
Large scale machine learning projects with R Suite
 
Large scale machine learning projects with r suite
Large scale machine learning projects with r suiteLarge scale machine learning projects with r suite
Large scale machine learning projects with r suite
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
 
Puppet Camp 2012
Puppet Camp 2012Puppet Camp 2012
Puppet Camp 2012
 
Ubic
UbicUbic
Ubic
 
Ubic-public
Ubic-publicUbic-public
Ubic-public
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
Practical Celery
Practical CeleryPractical Celery
Practical Celery
 
Get Grulping with JavaScript Task Runners
Get Grulping with JavaScript Task RunnersGet Grulping with JavaScript Task Runners
Get Grulping with JavaScript Task Runners
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 

Mehr von James Gray

In the Back of Your Mind
In the Back of Your MindIn the Back of Your Mind
In the Back of Your MindJames Gray
 
Unblocked
UnblockedUnblocked
UnblockedJames Gray
 
Module Magic
Module MagicModule Magic
Module MagicJames Gray
 
API Design
API DesignAPI Design
API DesignJames Gray
 
Amazon's Simple Storage Service (S3)
Amazon's Simple Storage Service (S3)Amazon's Simple Storage Service (S3)
Amazon's Simple Storage Service (S3)James Gray
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHubJames Gray
 
Test Coverage in Rails
Test Coverage in RailsTest Coverage in Rails
Test Coverage in RailsJames Gray
 
Rails Routing And Rendering
Rails Routing And RenderingRails Routing And Rendering
Rails Routing And RenderingJames Gray
 
Sending Email with Rails
Sending Email with RailsSending Email with Rails
Sending Email with RailsJames Gray
 
Associations in Rails
Associations in RailsAssociations in Rails
Associations in RailsJames Gray
 
DRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersDRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersJames Gray
 
Rails Model Basics
Rails Model BasicsRails Model Basics
Rails Model BasicsJames Gray
 
Wed Development on Rails
Wed Development on RailsWed Development on Rails
Wed Development on RailsJames Gray
 

Mehr von James Gray (14)

In the Back of Your Mind
In the Back of Your MindIn the Back of Your Mind
In the Back of Your Mind
 
Unblocked
UnblockedUnblocked
Unblocked
 
Module Magic
Module MagicModule Magic
Module Magic
 
API Design
API DesignAPI Design
API Design
 
Amazon's Simple Storage Service (S3)
Amazon's Simple Storage Service (S3)Amazon's Simple Storage Service (S3)
Amazon's Simple Storage Service (S3)
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Test Coverage in Rails
Test Coverage in RailsTest Coverage in Rails
Test Coverage in Rails
 
Rails Routing And Rendering
Rails Routing And RenderingRails Routing And Rendering
Rails Routing And Rendering
 
Sending Email with Rails
Sending Email with RailsSending Email with Rails
Sending Email with Rails
 
Associations in Rails
Associations in RailsAssociations in Rails
Associations in Rails
 
DRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersDRYing Up Rails Views and Controllers
DRYing Up Rails Views and Controllers
 
Rails Model Basics
Rails Model BasicsRails Model Basics
Rails Model Basics
 
Ruby
RubyRuby
Ruby
 
Wed Development on Rails
Wed Development on RailsWed Development on Rails
Wed Development on Rails
 

KĂźrzlich hochgeladen

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 productivityPrincipled Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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 AutomationSafe Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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 slidevu2urc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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...Miguel AraĂşjo
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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 Nanonetsnaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

KĂźrzlich hochgeladen (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Counting on God

  • 1. COUNTING ON GOD Can we?
  • 4. ELEMENTS OF MONITORED PROCESSES • PID les
  • 5. ELEMENTS OF MONITORED PROCESSES • PID les • Long running nature (decoupled start/stop)
  • 6. ELEMENTS OF MONITORED PROCESSES • PID les • Long running nature (decoupled start/stop) • Daemonization
  • 8. PID FILE BASICS module PIDFile module_function def create(path) open(path, File::CREAT | File::EXCL | File::WRONLY) do |pid| pid.flock(File::LOCK_EX) pid.puts Process.pid pid.flock(File::LOCK_UN) end at_exit do remove(path) end true rescue Errno::EEXIST # file already exists false end def remove(path) File.unlink(path) true rescue Exception false end end
  • 9. PID FILES IN ACTION require "pid_file" if PIDFile.create("show_pid.pid") puts "Running as #{Process.pid}..." sleep 10 puts "Shutting down." else puts "Already running." end
  • 10. PID FILES IN ACTION require "pid_file" if PIDFile.create("show_pid.pid") puts "Running as #{Process.pid}..." sleep 10 puts "Shutting down." else puts "Already running." end $ ruby -I . show_pid.rb Running as 3756... Shutting down.
  • 11. PID FILES IN ACTION require "pid_file" if PIDFile.create("show_pid.pid") puts "Running as #{Process.pid}..." sleep 10 puts "Shutting down." else puts "Already running." end $ ruby -I . show_pid.rb Running as 3756... Shutting down. $ cat show_pid.pid cat: show_pid.pid: No such file or directory $ ruby -I . show_pid.rb Already running. $ cat show_pid.pid 3756 $ cat show_pid.pid cat: show_pid.pid: No such file or directory
  • 13. LONG RUNNING PROCESSES require "pid_file" module LongRunningProcess module_function def manage(name, args = ARGV, &job) pid_path = "/Users/james/Desktop/#{name}.pid" if args.include? "stop" if pid = File.read(pid_path).to_i rescue nil Process.kill("TERM", pid) else puts "Not running." end else if PIDFile.create(pid_path) job.call else puts "Already running." end end end end
  • 14. LONG RUNNING PROCESSES IN ACTION require "long_running_process" LongRunningProcess.manage("show_long_running_process") do puts "Running as #{Process.pid}..." at_exit do puts "Shutting down." end loop do sleep end end
  • 15. LONG RUNNING PROCESSES IN ACTION require "long_running_process" LongRunningProcess.manage("show_long_running_process") do puts "Running as #{Process.pid}..." at_exit do puts "Shutting down." end loop do sleep end $ ruby -I . show_long_running_process.rb start end Running as 6970... Shutting down. Terminated
  • 16. LONG RUNNING PROCESSES IN ACTION require "long_running_process" LongRunningProcess.manage("show_long_running_process") do puts "Running as #{Process.pid}..." at_exit do puts "Shutting down." end loop do sleep end $ ruby -I . show_long_running_process.rb start end Running as 6970... Shutting down. Terminated $ cat show_long_running_process.pid cat: show_long_running_process.pid: No such file or directory $ cat show_long_running_process.pid 6970 $ ruby -I . show_long_running_process.rb start Already running. $ ruby -I . show_long_running_process.rb stop $ cat show_long_running_process.pid cat: show_long_running_process.pid: No such file or directory
  • 18. SUPPORTING DAEMONIZATION def create(path, &daemonize) open(path, File::CREAT | File::EXCL | File::WRONLY) do |pid| pid.flock(File::LOCK_EX) begin if daemonize.nil? or (daemonize.call rescue false) pid.puts Process.pid else return false end ensure pid.flock(File::LOCK_UN) end end at_exit do remove(path) end true rescue Errno::EEXIST # file already exists false end
  • 21. THE SMALLEST POSSIBLE GOD DESKTOP = "/Users/james/Desktop" RUBY = "ruby -I #{DESKTOP}" God.watch do |w| w.name = "show_long_running_process" w.interval = 30.seconds w.start = "#{RUBY} #{DESKTOP}/show_long_running_process.rb start" w.stop = "#{RUBY} #{DESKTOP}/show_long_running_process.rb stop" w.start_grace = 10.seconds w.restart_grace = 10.seconds w.pid_file = "#{DESKTOP}/show_long_running_process.pid" w.start_if do |start| start.condition(:process_running) do |c| c.interval = 5.seconds c.running = false end end end
  • 22. IN ACTION $ rvm 1.9.2 $ rvmsudo god -c minor_god.god -D I [2011-01-13 15:42:43] INFO: Loading minor_god.god I [2011-01-13 15:42:43] INFO: Syslog enabled. I [2011-01-13 15:42:43] INFO: Using pid file directory: /var/run/god I [2011-01-13 15:42:43] INFO: Started on drbunix:///tmp/god.17165.sock I [2011-01-13 15:42:43] INFO: show_long_running_process move 'unmonitored' to 'up' I [2011-01-13 15:42:43] INFO: show_long_running_process moved 'unmonitored' to 'up' I [2011-01-13 15:42:43] INFO: show_long_running_process [trigger] process is not running (ProcessRunning) I [2011-01-13 15:42:43] INFO: show_long_running_process move 'up' to 'start' I [2011-01-13 15:42:43] INFO: show_long_running_process start: ruby -I /Users/james/Desktop / Users/james/Desktop/show_long_running_process.rb start I [2011-01-13 15:42:53] INFO: show_long_running_process moved 'up' to 'up' I [2011-01-13 15:42:53] INFO: show_long_running_process [ok] process is running (ProcessRunning) I [2011-01-13 15:42:58] INFO: show_long_running_process [ok] process is running (ProcessRunning) I [2011-01-13 15:43:03] INFO: show_long_running_process [ok] process is running (ProcessRunning) I [2011-01-13 15:43:09] INFO: show_long_running_process [ok] process is running (ProcessRunning) ^C/Users/james/.rvm/gems/ruby-1.9.2-p136/gems/god-0.11.0/lib/god.rb:656:in `join': Interrupt from /Users/james/.rvm/gems/ruby-1.9.2-p136/gems/god-0.11.0/lib/god.rb:656:in `start' from /Users/james/.rvm/gems/ruby-1.9.2-p136/gems/god-0.11.0/lib/god.rb:667:in `at_exit' from /Users/james/.rvm/gems/ruby-1.9.2-p136/gems/god-0.11.0/lib/god.rb:700:in `block in <top (required)>'
  • 23. DOING EVIL UNDER GOD’S GAZE $ rvmsudo god -c minor_god.god $ ps auxww | grep show_long_running_process root 1986 0.2 0.0 2448168 952 ?? S 3:56PM 0:00.02 ruby - I /Users/james/Desktop /Users/james/Desktop/show_long_running_process.rb start james 1988 0.0 0.0 2435116 532 s000 S+ 3:57PM 0:00.00 grep show_long_running_process $ sudo kill 1986 $ ps auxww | grep show_long_running_process root 1996 0.2 0.0 2448168 936 ?? S 3:57PM 0:00.00 ruby - I /Users/james/Desktop /Users/james/Desktop/show_long_running_process.rb start james 1998 0.0 0.0 2435116 532 s000 S+ 3:57PM 0:00.00 grep show_long_running_process $ rvmsudo god terminate .. Stopped all watches Stopped god $ ps auxww | grep show_long_running_process james 2005 0.0 0.0 2435116 532 s000 S+ 3:57PM 0:00.00 grep show_long_running_process
  • 25. CLEANING PID FILES w.behavior(:clean_pid_file)
  • 26. CONDITIONAL RESTARTS w.restart_if do |restart| restart.condition(:memory_usage) do |c| c.above = 150.megabytes c.times = [3, 5] # 3 out of 5 intervals end restart.condition(:cpu_usage) do |c| c.above = 50.percent c.times = 5 end end
  • 27. CONTROLLING DEATH w.lifecycle do |on| on.condition(:flapping) do |c| c.to_state = [:start, :restart] c.times = 5 c.within = 5.minute c.transition = :unmonitored c.retry_in = 10.minutes c.retry_times = 5 c.retry_within = 2.hours end end
  • 28. THE POWER OF GOD # determine the state on startup w.transition(:init, { true => :up, false => :start }) do |on| on.condition(:process_running) do |c| c.running = true end end # determine when process has finished starting w.transition([:start, :restart], :up) do |on| on.condition(:process_running) do |c| # start if process is not running c.running = true w.transition(:up, :start) do |on| end on.condition(:process_exits) end # failsafe on.condition(:tries) do |c| # restart if memory or cpu is too high c.times = 5 w.transition(:up, :restart) do |on| c.transition = :start on.condition(:memory_usage) do |c| end c.interval = 20 end c.above = 50.megabytes c.times = [3, 5] end on.condition(:cpu_usage) do |c| c.interval = 10 c.above = 10.percent c.times = [3, 5] end end
  • 30. HOW BIG IS GOD? $ ps -p 2177 -o pid,%mem,rss,command PID %MEM RSS COMMAND 2177 0.2 16624 /Users/james/.rvm/rubies/ruby-1.9.2-p136/bin/ruby /Users/jame $ ps -p 2184 -o pid,%mem,rss,command PID %MEM RSS COMMAND 2184 0.0 928 ruby -I /Users/james/Desktop /Users/james/Desktop/show_long_r
  • 32. GOD’S JOY • Super easy gem install and setup
  • 33. GOD’S JOY • Super easy gem install and setup • It works on Ruby 1.9.2
  • 34. GOD’S JOY • Super easy gem install and setup • It works on Ruby 1.9.2 • Ruby DSL can be handy
  • 35. GOD’S JOY • Super easy gem install and setup • It works on Ruby 1.9.2 • Ruby DSL can be handy • Very congurable with lots of options
  • 37. THE PRICE OF GOD • Ruby DSL isn’t at all natural
  • 38. THE PRICE OF GOD • Ruby DSL isn’t at all natural • God process in moderately expensive
  • 39. THE PRICE OF GOD • Ruby DSL isn’t at all natural • God process in moderately expensive • God leaked memory in the past (I think this is resolved now)

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n