Class: Trinidad::Extensions::ThreadedResque::LifecycleListener
- Inherits:
-
Object
- Object
- Trinidad::Extensions::ThreadedResque::LifecycleListener
- Includes:
- Tomcat::LifecycleListener
- Defined in:
- lib/trinidad_threaded_resque_extension/lifecycle_listener.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#threads ⇒ Object
Returns the value of attribute threads.
-
#workers ⇒ Object
Returns the value of attribute workers.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ LifecycleListener
constructor
A new instance of LifecycleListener.
- #lifecycleEvent(event) ⇒ Object
- #start_workers ⇒ Object
- #stop_workers ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ LifecycleListener
Returns a new instance of LifecycleListener.
10 11 12 |
# File 'lib/trinidad_threaded_resque_extension/lifecycle_listener.rb', line 10 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/trinidad_threaded_resque_extension/lifecycle_listener.rb', line 8 def @options end |
#threads ⇒ Object
Returns the value of attribute threads.
8 9 10 |
# File 'lib/trinidad_threaded_resque_extension/lifecycle_listener.rb', line 8 def threads @threads end |
#workers ⇒ Object
Returns the value of attribute workers.
8 9 10 |
# File 'lib/trinidad_threaded_resque_extension/lifecycle_listener.rb', line 8 def workers @workers end |
Instance Method Details
#lifecycleEvent(event) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/trinidad_threaded_resque_extension/lifecycle_listener.rb', line 14 def lifecycleEvent(event) case event.type when Trinidad::Tomcat::Lifecycle::AFTER_START_EVENT start_workers when Trinidad::Tomcat::Lifecycle::BEFORE_STOP_EVENT stop_workers end end |
#start_workers ⇒ Object
23 24 25 26 27 |
# File 'lib/trinidad_threaded_resque_extension/lifecycle_listener.rb', line 23 def start_workers pre_require @workers = create_workers @threads = create_threads end |
#stop_workers ⇒ Object
29 30 31 32 |
# File 'lib/trinidad_threaded_resque_extension/lifecycle_listener.rb', line 29 def stop_workers @workers.each { |w| w.shutdown } if @workers @threads.each { |t| t.join } if @threads end |