Class: Trinidad::Extensions::Sidekiq::LifecycleListener
- Inherits:
-
Object
- Object
- Trinidad::Extensions::Sidekiq::LifecycleListener
- Includes:
- Tomcat::LifecycleListener
- Defined in:
- lib/trinidad_sidekiq_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_cli ⇒ Object
- #stop_cli ⇒ Object
Constructor Details
#initialize(options = { }) ⇒ LifecycleListener
Returns a new instance of LifecycleListener.
8 9 10 |
# File 'lib/trinidad_sidekiq_extension/lifecycle_listener.rb', line 8 def initialize( = { }) = || {} end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/trinidad_sidekiq_extension/lifecycle_listener.rb', line 6 def end |
#threads ⇒ Object
Returns the value of attribute threads.
6 7 8 |
# File 'lib/trinidad_sidekiq_extension/lifecycle_listener.rb', line 6 def threads @threads end |
#workers ⇒ Object
Returns the value of attribute workers.
6 7 8 |
# File 'lib/trinidad_sidekiq_extension/lifecycle_listener.rb', line 6 def workers @workers end |
Instance Method Details
#lifecycleEvent(event) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/trinidad_sidekiq_extension/lifecycle_listener.rb', line 12 def lifecycleEvent(event) case event.type when Trinidad::Tomcat::Lifecycle::AFTER_START_EVENT STDOUT << "[Trinidad:Sidekiq] event [#{event.type}] << start >>\n" if [:verbose] start_cli when Trinidad::Tomcat::Lifecycle::BEFORE_STOP_EVENT STDOUT << "[Trinidad:Sidekiq] event [#{event.type}] << stop >>\n" if [:verbose] stop_cli else STDOUT << "[Trinidad:Sidekiq] event [#{event.type}] skipped\n" if [:verbose] end end |
#start_cli ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/trinidad_sidekiq_extension/lifecycle_listener.rb', line 25 def start_cli STDOUT << "[Trinidad:Sidekiq] starting sidekiq bm with options [#{@options}]\n" if [:verbose] unless [:require] raise "You probably want to send a require option to the sidekiq background manager ..." if [:verbose] end STDOUT << "[Trinidad:Sidekiq] getting it going ...\n" bm = ::Sidekiq::BackgroundManager.instance STDOUT << "[Trinidad:Sidekiq] got original bm (#{bm.class.name}) #{bm.inspect} ...\n" if [:verbose] bm.configure STDOUT << "[Trinidad:Sidekiq] got modified bm (#{bm.class.name}) #{bm.inspect} ...\n" if [:verbose] res = bm.run STDOUT << "[Trinidad:Sidekiq] got bm running (#{res.class.name}) #{res.inspect} ...\n" if [:verbose] end |
#stop_cli ⇒ Object
40 41 42 43 44 |
# File 'lib/trinidad_sidekiq_extension/lifecycle_listener.rb', line 40 def stop_cli STDOUT << "[Trinidad:Sidekiq] Stopping sidekiq cli ...\n" if [:verbose] res = ::Sidekiq::BackgroundManager.instance.interrupt STDOUT << "[Trinidad:Sidekiq] got bm stopped (#{res.class.name})#{res.inspect} ...\n" if [:verbose] end |