module Rakwik
Constants
- VERSION
Public Class Methods
die_gracefully_on_signal()
click to toggle source
# File lib/rakwik.rb, line 34 def self.die_gracefully_on_signal Signal.trap("INT") { EM.stop } Signal.trap("TERM") { EM.stop } end
start()
click to toggle source
Taken from www.hiringthing.com/2011/11/04/eventmachine-with-rails.html Thanks Joshua!
# File lib/rakwik.rb, line 7 def self.start if defined?(PhusionPassenger) PhusionPassenger.on_event(:starting_worker_process) do |forked| # for passenger, we need to avoid orphaned threads if forked && EM.reactor_running? EM.stop end Thread.new { EM.run do puts "=> EventMachine started" end } die_gracefully_on_signal end else # faciliates debugging Thread.abort_on_exception = true # just spawn a thread and start it up Thread.new { EM.run do puts "=> EventMachine started" end } unless defined?(Thin) # Thin is built on EventMachine, doesn't need this thread end end