Class: Mysqlcollector::Deamon

Inherits:
Object
  • Object
show all
Defined in:
lib/mysqlcollector/daemon.rb

Instance Method Summary collapse

Constructor Details

#initialize(method) ⇒ Deamon

Returns a new instance of Deamon.



5
6
7
# File 'lib/mysqlcollector/daemon.rb', line 5

def initialize(method)
  @method = method
end

Instance Method Details

#run!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mysqlcollector/daemon.rb', line 9

def run!
  begin
    puts "Press Ctrl-C to stop MySQL Collector"

    loop do
      eval(@method)
      sleep(30)
    end
  rescue Interrupt
    puts "\n"

    # Appendix E. Exit Codes With Special Meanings
    # http://tldp.org/LDP/abs/html/exitcodes.html
    exit 130
  end
end