kenichi / angelo

Sinatra-like DSL for Reel that supports WebSockets and SSE
Other
303 stars 23 forks source link

How to start a supervised server? #55

Closed pinyin closed 9 years ago

pinyin commented 9 years ago

Hi,

Thanks for the elegant work.

It seems that Angelo::Base.run() uses Angelo::Server.new to start a new server instance, so I cannot call Angelo::Server.supervise_as manually like using other Celluloid actors.

Is there a recommended way to make a supervised server always available in Celluloid::Actor[]?

kenichi commented 9 years ago

@pinyin thank you! there wasn't one, but what do you think about this?

https://github.com/kenichi/angelo/compare/supervise

used something like this:

require 'angelo'
class S < Angelo::Base
  get '/' do
    ''
  end
end
s = S.run S.addr, S.port, supervise_as: :s
puts "supervised: #{Celluloid::Actor[:s]}"
sleep

makes me want to change the api of Base#run and #run! to take opts hash only...

digitalextremist commented 9 years ago

@kenichi and make sure you anticipate 0.17.0 where supervise_as is no longer used!

kenichi commented 9 years ago

@digitalextremist ah good to know. 0.17.0 is huge, can you point me to any specifics about this?

digitalextremist commented 9 years ago

Well @kenichi, for one, supervision moved to its own gem: celluloid-supervision ... but as of now, 0.17.0 includes that gem out-of-the-box. In the future, it may not. Doesn't hurt to include that gem then.

As of now, you need to add submodules: true and use github in your Gemfile ...

As for specific syntax, you will be using as: :name or name: :name ( an alias ) ... and using #supervise

And documentation of changes is sparse right now, which I am working on. Mostly there is new example code and updated tests.

pinyin commented 9 years ago

Ah that's super fast!

Thanks. My issue is closed.