Class: Messed::EMRunner

Inherits:
Object
  • Object
show all
Includes:
Logger::LoggingModule
Defined in:
lib/messed/em_runner.rb

Defined Under Namespace

Classes: StatusHandler

Instance Method Summary collapse

Methods included from Logger::LoggingModule

included, #logger, #logger=

Constructor Details

#initialize(options, &block) ⇒ EMRunner

Returns a new instance of EMRunner.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/messed/em_runner.rb', line 27

def initialize(options, &block)
  logger.info "Starting..." unless options[:supress_banner]
  if options[:detach]
    pid = EM.fork_reactor do
      trap("INT") { EM.stop_reactor_loop }
      EM.run do
        EM.next_tick(&block)
      end
    end
    Process.detach(pid)
    exit(0)
  else
    EM.run do
      EM.next_tick(&block)
    end
  end
end

Instance Method Details

#quitObject



45
46
47
# File 'lib/messed/em_runner.rb', line 45

def quit
  EM.stop; logger.info "\nStoping #{interface.name.to_s}"; exit(0)
end