1
0
Fork 0
mirror of https://github.com/endofunky/sidetiq.git synced 2022-11-09 13:53:30 -05:00
endofunky--sidetiq/lib/sidetiq/supervisor.rb
Simon Fröhler 7bec408416 Makes Sidekiq compatible to Sidekiq 3.5.0 and Celluloid 0.17
Fixes "uninitialized constant Celluloid::SupervisionGroup" error on sidekiq start:

* require 'celluloid' instead of 'celluloid/current' in lib/sidetiq.rb
* Supervisor inherits from Celluloid::Supervision::Container instead
  of Celluloid::SupervisionGroup and uses new supervise method signature

More details about the changes in Celluloid can be found here:
https://github.com/celluloid/celluloid/wiki/DEPRECATION-WARNING

Fixes tests to work with Sidekiq 3.5.0:

* Use created_at instead of enqueued_at it the tests:
  > Set a created_at attribute when jobs are created, set enqueued_at only
    when they go into a queue. Fixes invalid latency calculations with
    scheduled jobs. [#2373, mrsimo]

  https://github.com/mperham/sidekiq/blob/master/Changes.md#340

* Set ENV['RACK_ENV'] = 'test' in test/helper.rb to fix tests to fix tests
  to work with Sidekiq 3.4.2 update:
  > Fix CSRF vulnerability in Web UI, thanks to Egor Homakov for reporting. [#2422]

  https://github.com/mperham/sidekiq/blob/master/Changes.md#342
  https://github.com/mperham/sidekiq/pull/2422/files

fixes #140
2015-09-08 15:45:17 +02:00

49 lines
1.3 KiB
Ruby

module Sidetiq
class Supervisor < Celluloid::Supervision::Container
supervise type: Sidetiq::Actor::Clock, as: :sidetiq_clock
if Sidekiq.server?
if handler_pool_size = Sidetiq.config.handler_pool_size
pool Sidetiq::Actor::Handler,
as: :sidetiq_handler,
size: handler_pool_size
else
# Use Celluloid's CPU-based default.
pool Sidetiq::Actor::Handler,
as: :sidetiq_handler
end
end
class << self
include Logging
def clock
run! if Celluloid::Actor[:sidetiq_clock].nil?
Celluloid::Actor[:sidetiq_clock]
end
def handler
run! if Celluloid::Actor[:sidetiq_handler].nil?
Celluloid::Actor[:sidetiq_handler]
end
def run!
motd
info "Sidetiq::Supervisor start"
super
end
def run
raise "Sidetiq::Supervisor should not be run in foreground."
end
private
def motd
info "Sidetiq v#{VERSION::STRING} - Copyright (c) 2012-2013, Tobias Svensson <tob@tobiassvensson.co.uk>"
info "Sidetiq is covered by the 3-clause BSD license."
info "See LICENSE and http://opensource.org/licenses/BSD-3-Clause for licensing details."
end
end
end
end