Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

'stop' method for Rack::Handler::Reel #43

Closed
digitalextremist opened this issue Apr 16, 2013 · 17 comments
Closed

'stop' method for Rack::Handler::Reel #43

digitalextremist opened this issue Apr 16, 2013 · 17 comments

Comments

@digitalextremist
Copy link
Member

NoMethodError: undefined method `stop' for #<Rack::Handler::Reel:0x29874744>

Shutting down a Rack-based implementation of Reel with Ctrl-C, the above fires, so there is no graceful shutdown... even though the previous line in the console is Terminating # actors...

Tried adding this tp Rack::Handler::Reel, but it doesn't seem to help:

def self.stop
  ::Reel::Server.terminate
end
@halorgium
Copy link
Contributor

@digitalextremist I don't believe there is a class method for terminate.
You will need to use the instance method.

@digitalextremist
Copy link
Member Author

I will look at that, but what I mean is, def self.stop is not satisfying the requirement for a stop method on Rack::Handler::Reel, and I am not sure why @halorgium.

@halorgium
Copy link
Contributor

Use an instance method.

@tarcieri
Copy link
Member

Unfortunately I didn't write the Rack adapter and don't know a whole lot about how it works :( Ideally it has access to the Reel instance servicing the requests, and the stop class method can look up the Reel instance and call the #terminate instance method on it.

@digitalextremist
Copy link
Member Author

Ok, cool. Thanks to you both. I'll go with an instance method and follow the breadcrumbs on what you just said to try to gracefully kill Reel. _why oh _why am I the one to stumble upon where the sidewalks end :) This isn't ridiculously important, thankfully.

@halorgium
Copy link
Contributor

@digitalextremist you are defining a class method on the Rack::Handler::Reel class, it is trying to invoke the instance method.

@digitalextremist
Copy link
Member Author

Don't worry, I get what you're saying @halorgium. What's still true is that regardless, no stop in any form exists right now. Experimenting with def stop. OK. def stop works, now I need to move on to what @tarcieri said about finding the place to terminate Reel. I am not sufficiently acquainted with Celluloid to know where that might be, but I look forward to knowing that.

@digitalextremist
Copy link
Member Author

Hahaha. Please, please no one post a pull request with a functioning def stop. I want my first contribution to be "stopping Reel" :)

@tarcieri
Copy link
Member

@digitalextremist go for it

@digitalextremist
Copy link
Member Author

Progress! So far I've figured out how to make sure that Reel never, ever dies, no matter how many times you try to kill it, short of a -9.

@digitalextremist
Copy link
Member Author

Ok I figured it out, I think. This seems to work immediately and cleanly, in this order:

      def stop
        Celluloid::Actor[:reel_server].terminate
        Celluloid::Actor[:reel_rack_pool].terminate
        exit
      end

Without each of those lines, Reel seems to either keep going, or not kill some part of itself, itself.

@halorgium
Copy link
Contributor

You might want to keep celluloid/celluloid#150 in mind.

@digitalextremist
Copy link
Member Author

If that seems right I'll post a pull request with it.

Is exit bad form here? It seems to be all that works to actually put a bullet in Reel.

@tarcieri
Copy link
Member

exit is totally fine

@digitalextremist
Copy link
Member Author

Cool! I have affected death properly. I will commit my dr. kevorkian pull request.

@halorgium
Copy link
Contributor

I do have to suggest that exit would be OK now, but if Reel was underneath another actor and passed to the Rack handler, it would be better to let the parent handle the terminate.

@digitalextremist
Copy link
Member Author

When I graduate from Celluloid University I'll come touch up my first commit to Reel with that in mind @halorgium.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants