Skip to content

Commit

Permalink
Use Celluloid's "current" mode
Browse files Browse the repository at this point in the history
Avoids breakage in backward compatibility: see https://github.com/celluloid/celluloid-pool/issues/14
  • Loading branch information
benlangfeld committed Dec 17, 2015
1 parent ad9a320 commit 73acd37
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ source 'https://rubygems.org'
gemspec

gem 'sinatra', require: nil
gem 'reel', github: 'celluloid/reel'
2 changes: 1 addition & 1 deletion adhearsion.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'nokogiri', ["~> 1.5", ">= 1.5.6"]
s.add_runtime_dependency 'pry'
s.add_runtime_dependency 'rake'
s.add_runtime_dependency 'reel', ["~> 0.5.0"]
s.add_runtime_dependency 'reel', ["~> 0.6.0.pre5"]
s.add_runtime_dependency 'reel-rack', ["~> 0.2.0"]
s.add_runtime_dependency 'ruby_ami', ["~> 2.2"]
s.add_runtime_dependency 'ruby_jid', ["~> 1.0"]
Expand Down
4 changes: 2 additions & 2 deletions lib/adhearsion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
abort "ERROR: You are running Adhearsion on an unsupported version of Ruby (Ruby #{RUBY_VERSION} #{RUBY_RELEASE_DATE})! Please upgrade to at least Ruby v2.2.0 or JRuby 9.0.0.0." if RUBY_VERSION < "2.2"

%w(
celluloid/current
adhearsion/rayo
celluloid
active_support/inflector
).each { |r| require r }

Expand Down Expand Up @@ -71,7 +71,7 @@ def active_calls=(other)
# @return [Adhearsion::Statistics] a statistics aggregator object capable of producing stats dumps
def statistics
unless Celluloid::Actor[:statistics]
Statistics.supervise_as :statistics
Statistics.supervise as: :statistics
Statistics.setup_event_handlers
end
Celluloid::Actor[:statistics]
Expand Down
6 changes: 4 additions & 2 deletions lib/adhearsion/http_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

module Adhearsion
# @private
class HTTPServer
class HTTPServer < Reel::Rack::Server
include Celluloid::Internals::Logger

def self.start
config = Adhearsion.config.core.http

Expand All @@ -27,7 +29,7 @@ def self.start

logger.info "Starting HTTP server listening on #{config.host}:#{config.port}"

supervisor = ::Reel::Rack::Server.supervise_as(:ahn_http_server, app, options)
supervisor = self.supervise(as: :ahn_http_server, args: [app, options])

Adhearsion::Events.register_callback :shutdown do
supervisor.terminate
Expand Down
8 changes: 5 additions & 3 deletions lib/adhearsion/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ def final_shutdown
call.hangup
end

Adhearsion::Events.register_callback :shutdown do
logger.info "Adhearsion shut down"
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
Events.trigger :shutdown

Console.stop

logger.info "Adhearsion shut down"
end

def stop_when_zero_calls
Expand Down

0 comments on commit 73acd37

Please sign in to comment.