celluloid / reel

UNMAINTAINED: See celluloid/celluloid#779 - Celluloid::IO-powered web server
https://celluloid.io
MIT License
596 stars 87 forks source link

Reel::Server shutdown does not handle IOError #212

Open promix17 opened 8 years ago

promix17 commented 8 years ago

Reel::Server shutdown does not handle IOError

https://github.com/celluloid/reel/blob/master/lib/reel/server.rb

E, [2015-11-27T13:16:50.854783 #9223] ERROR -- : HttpServer finalizer crashed!
IOError: closed stream
/var/lib/gems/1.9.1/gems/reel-0.5.0/lib/reel/server.rb:34:in `shutdown'
/var/lib/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/cell.rb:84:in `block in shutdown'
/var/lib/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/cell.rb:76:in `block in task'
/var/lib/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/actor.rb:339:in `block in task'
/var/lib/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/task.rb:44:in `block in initialize'
/var/lib/gems/1.9.1/gems/celluloid-0.17.2/lib/celluloid/task/fibered.rb:14:in `block in create'

Example

require 'celluloid/autostart'
require 'reel'

class HttpServer < Reel::Server::HTTP
  def initialize(params={})
    params = {
      :host => '0.0.0.0',
      :port => 8080
    }.merge(params)
    host, port = params.values_at(:host, :port)
    super(host, port, &method(:on_connection))
  end

  def on_connection(connection)
    connection.each_request do |request|
      request.respond 503, 'Server error'
    end
  end
end

server = HttpServer.new(:port => 8081)
server.shutdown

Gems

celluloid (0.17.2, 0.16.0)
celluloid-dns (0.17.0, 0.0.1)
celluloid-essentials (0.20.5)
celluloid-extras (0.20.5)
celluloid-fsm (0.20.5)
celluloid-io (0.17.2, 0.16.2)
celluloid-pool (0.20.5)
celluloid-supervision (0.20.5)
digitalextremist commented 8 years ago

I vaguely recall this one. Have you happened to try the 0.6.0-milestone branch?

MidnightsFX commented 7 years ago

Still seeing this with 6.1.

Initializing the reel server with super and a Reel::Server::HTTP class. Similar as to above.

E, [2017-01-31T11:48:17.635000 #64215] ERROR -- : CLEANUP CRASHED! IOError: closed stream org/nio4r/Selector.java:123:in 'deregister' org/nio4r/Monitor.java:154:in 'close' org/nio4r/Monitor.java:145:in 'close' /jruby-9.1.6.0/gems/celluloid-io-0.17.3/lib/celluloid/io/reactor.rb:52:in 'wait' /jruby-9.1.6.0/gems/celluloid-io-0.17.3/lib/celluloid/io/reactor.rb:21:in 'wait_readable' /jruby-9.1.6.0/gems/celluloid-io-0.17.3/lib/celluloid/io.rb:54:in 'wait_readable' /jruby-9.1.6.0/gems/celluloid-io-0.17.3/lib/celluloid/io/tcp_server.rb:36:in 'accept' /jruby-9.1.6.0/gems/reel-0.6.1/lib/reel/server.rb:38:in 'block in run' org/jruby/RubyKernel.java:1299:in 'loop' /jruby-9.1.6.0/gems/reel-0.6.1/lib/reel/server.rb:38:in 'run' org/jruby/RubyKernel.java:1811:in 'public_send' /jruby-9.1.6.0/gems/celluloid-0.17.3/lib/celluloid/calls.rb:28:in 'dispatch' /jruby-9.1.6.0/gems/celluloid-0.17.3/lib/celluloid/call/async.rb:7:in 'dispatch' /jruby-9.1.6.0/gems/celluloid-0.17.3/lib/celluloid/cell.rb:50:in 'block in dispatch' /jruby-9.1.6.0/gems/celluloid-0.17.3/lib/celluloid/cell.rb:76:in 'block in task' /jruby-9.1.6.0/gems/celluloid-0.17.3/lib/celluloid/actor.rb:339:in 'block in task' /jruby-9.1.6.0/gems/celluloid-0.17.3/lib/celluloid/task.rb:44:in 'block in initialize' /jruby-9.1.6.0/gems/celluloid-0.17.3/lib/celluloid/task/fibered.rb:14:in 'block in create'

Getting one error message on program exit for every time the server is shutdown.

chewi commented 7 years ago

I've submitted a fix.

MidnightsFX commented 7 years ago

Hey @chewi is there a build, or branch I can build to take a look at your fix?

chewi commented 7 years ago

See #240.