Skip to content

Commit

Permalink
Merge 2f9ca29 into d84b67a
Browse files Browse the repository at this point in the history
  • Loading branch information
halorgium committed Apr 19, 2013
2 parents d84b67a + 2f9ca29 commit 8829524
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
18 changes: 18 additions & 0 deletions lib/celluloid.rb
Expand Up @@ -71,6 +71,23 @@ def boot
Celluloid::IncidentReporter.supervise_as :default_incident_reporter, STDERR
end

def register_shutdown
return if @shutdown_registered
# Terminate all actors at exit
at_exit do
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9"
# workaround for MRI bug losing exit status in at_exit block
# http://bugs.ruby-lang.org/issues/5218
exit_status = $!.status if $!.is_a?(SystemExit)
Celluloid.shutdown
exit exit_status if exit_status
else
Celluloid.shutdown
end
end
@shutdown_registered = true
end

# Shut down all running actors
def shutdown
Timeout.timeout(shutdown_timeout) do
Expand Down Expand Up @@ -516,3 +533,4 @@ def future(meth = nil, *args, &block)
Celluloid.task_class = Celluloid::TaskFiber
Celluloid.logger = Logger.new(STDERR)
Celluloid.shutdown_timeout = 10
Celluloid.register_shutdown
13 changes: 0 additions & 13 deletions lib/celluloid/autostart.rb
@@ -1,16 +1,3 @@
require 'celluloid'

Celluloid.boot

# Terminate all actors at exit
at_exit do
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9"
# workaround for MRI bug losing exit status in at_exit block
# http://bugs.ruby-lang.org/issues/5218
exit_status = $!.status if $!.is_a?(SystemExit)
Celluloid.shutdown
exit exit_status if exit_status
else
Celluloid.shutdown
end
end

0 comments on commit 8829524

Please sign in to comment.