Module: Sidekiq::HerokuAutoscale
- Defined in:
- lib/sidekiq/heroku_autoscale.rb,
lib/sidekiq/heroku_autoscale/process.rb,
lib/sidekiq/heroku_autoscale/version.rb,
lib/sidekiq/heroku_autoscale/heroku_app.rb,
lib/sidekiq/heroku_autoscale/middleware.rb,
lib/sidekiq/heroku_autoscale/queue_system.rb,
lib/sidekiq/heroku_autoscale/poll_interval.rb,
lib/sidekiq/heroku_autoscale/web_extension.rb,
lib/sidekiq/heroku_autoscale/scale_strategy.rb
Defined Under Namespace
Modules: WebExtension
Classes: HerokuApp, Middleware, PollInterval, Process, QueueSystem, ScaleStrategy
Constant Summary
collapse
- VERSION =
'0.0.1'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.exception_handler ⇒ Object
58
59
60
61
62
63
|
# File 'lib/sidekiq/heroku_autoscale.rb', line 58
def exception_handler
@exception_handler ||= lambda { |ex|
p ex
puts ex.backtrace
}
end
|
Class Method Details
.app ⇒ Object
13
14
15
|
# File 'lib/sidekiq/heroku_autoscale.rb', line 13
def app
@app
end
|
.init(options) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/sidekiq/heroku_autoscale.rb', line 17
def init(options)
options = options.transform_keys(&:to_sym)
@app = HerokuApp.new(options)
::Sidekiq.logger.warn('Heroku platform API is not configured for Sidekiq::HerokuAutoscale') unless @app.live?
::Sidekiq.configure_server do |config|
config.on(:startup) do
dyno_name = ENV['DYNO']
next unless dyno_name
process = @app.process_by_name(dyno_name.split('.').first)
next unless process
process.ping!
end
config.server_middleware do |chain|
chain.add(Middleware, @app)
end
config.client_middleware do |chain|
chain.add(Middleware, @app)
end
end
::Sidekiq.configure_client do |config|
config.client_middleware do |chain|
chain.add(Middleware, @app)
end
end
@app.ping! unless ::Sidekiq.server?
@app
end
|