Class: Sponges::Runner
- Inherits:
-
Object
- Object
- Sponges::Runner
- Defined in:
- lib/sponges/runner.rb
Overview
This class concern is to create a Supervisor, set some signals handlers and watch over the supervisor.
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
-
#initialize(name, options = {}, block) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
Constructor Details
#initialize(name, options = {}, block) ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 13 14 15 16 17 |
# File 'lib/sponges/runner.rb', line 9 def initialize(name, = {}, block) @name, @block = name, block @options = .merge @store = Sponges::Store.new(@name) if store.running? Sponges.logger.error "Runner #{@name} already started." exit end end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
7 8 9 |
# File 'lib/sponges/runner.rb', line 7 def store @store end |
Instance Method Details
#start ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sponges/runner.rb', line 19 def start if daemonize? Sponges.logger.info "Supervisor daemonized." Process.daemon end Sponges.logger.info "Runner #{@name} start message received." @supervisor = fork_supervisor trap_signals Sponges.logger.info "Supervisor started with #{@supervisor} pid." Process.waitpid(@supervisor) unless daemonize? end |