class Adhearsion::Process
Attributes
important_threads[RW]
Public Class Methods
method_missing(method_name, *args, &block)
click to toggle source
# File lib/adhearsion/process.rb, line 113 def self.method_missing(method_name, *args, &block) instance.send method_name, *args, &block end
new()
click to toggle source
Calls superclass method
# File lib/adhearsion/process.rb, line 61 def initialize @important_threads = ThreadSafeArray.new super end
Public Instance Methods
die_now!()
click to toggle source
# File lib/adhearsion/process.rb, line 105 def die_now! ::Process.exit 1 end
final_shutdown()
click to toggle source
# File lib/adhearsion/process.rb, line 80 def final_shutdown Adhearsion.active_calls.each do |_, call| call.hangup end # This should shut down any remaining threads. Once those threads have # stopped, important_threads will be empty and the process will exit # normally. Events.trigger_immediately :shutdown Console.stop logger.info "Adhearsion shut down" end
fqdn()
click to toggle source
# File lib/adhearsion/process.rb, line 109 def fqdn Socket.gethostbyname(Socket.gethostname).first end
log_state_change(transition)
click to toggle source
# File lib/adhearsion/process.rb, line 66 def log_state_change(transition) event, from, to = transition.event, transition.from_name, transition.to_name logger.info "Transitioning from #{from} to #{to} with #{Adhearsion.active_calls.size} active calls due to #{event} event." end
quiesce()
click to toggle source
# File lib/adhearsion/process.rb, line 76 def quiesce Events.trigger_immediately :quiesced end
request_stop()
click to toggle source
# File lib/adhearsion/process.rb, line 71 def request_stop Events.trigger_immediately :stop_requested important_threads << Thread.new { stop_when_zero_calls } end
stop_when_zero_calls()
click to toggle source
# File lib/adhearsion/process.rb, line 95 def stop_when_zero_calls i = 0 until Adhearsion.active_calls.count == 0 logger.info "Stop requested but we still have #{Adhearsion.active_calls.count} active calls." if (i % 50) == 0 sleep 0.2 i += 1 end final_shutdown end