Class: Hashdot::Daemon::Runner
- Inherits:
-
Object
- Object
- Hashdot::Daemon::Runner
- Includes:
- RJack
- Defined in:
- lib/hashdot-test-daemon.rb
Overview
The mock service
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
30 31 32 33 34 35 |
# File 'lib/hashdot-test-daemon.rb', line 30 def initialize @log = SLF4J[ self.class ] @log.info "Initialized hashdot-daemon (VERSION = #{VERSION})" @log.info "SLF4J::VERSION = #{SLF4J::VERSION}" ShutdownHandler.register end |
Instance Method Details
#run ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/hashdot-test-daemon.rb', line 37 def run loop do i = 2 * rand @log.info { "Sleep #{i}" } sleep i if rand(100) == 0 cause = rand(3) == 0 ? "KILL" : "TERM" @log.info { "Unexpected #{cause}" } Process.kill( cause, 0 ) break end end end |