Class: Sponges::Supervisor
- Inherits:
-
Object
- Object
- Sponges::Supervisor
- Extended by:
- Forwardable
- Defined in:
- lib/sponges/supervisor.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name, options, store, block) ⇒ Supervisor
constructor
A new instance of Supervisor.
- #start ⇒ Object
Constructor Details
#initialize(name, options, store, block) ⇒ Supervisor
Returns a new instance of Supervisor.
9 10 11 12 13 14 15 16 |
# File 'lib/sponges/supervisor.rb', line 9 def initialize(name, , store, block) @name, @options, @store, @block = name, , store, block $PROGRAM_NAME = [@name, Sponges.env, "supervisor"].compact.join("_") store.register Process.pid @children_seen = 0 @handler = Handler.new self @listener = Listener.new(self) end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
5 6 7 |
# File 'lib/sponges/supervisor.rb', line 5 def handler @handler end |
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
5 6 7 |
# File 'lib/sponges/supervisor.rb', line 5 def listener @listener end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sponges/supervisor.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/sponges/supervisor.rb', line 5 def @options end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
5 6 7 |
# File 'lib/sponges/supervisor.rb', line 5 def store @store end |
Instance Method Details
#call ⇒ Object
34 35 36 |
# File 'lib/sponges/supervisor.rb', line 34 def call @block.call end |
#start ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sponges/supervisor.rb', line 18 def start handler.call trap_signals [:size].times do handler.push :TTIN end Sponges.logger.info "Supervisor started, waiting for messages, listening on port #{Sponges::Configuration.port}" listener.call rescue SystemExit => exception raise exception rescue Exception => exception Sponges.logger.error exception handler.push :INT raise exception end |