Sha256: b4d7b2e43a8ae95cdbfd74a58b2ec44be4a75f7356323b27a6f72635052ec1fa
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
require 'resque/cluster' module Resque # Resque Pool monkey patched methods for resque-pool class Pool # add the running pool to distributed pool in order to manipulate it def self.run if GC.respond_to?(:copy_on_write_friendly=) GC.copy_on_write_friendly = true end pool_config = Resque::Cluster.config ? {} : choose_config_file started_pool = Resque::Pool.new(pool_config).start Resque::Cluster.init(started_pool) if Resque::Cluster.config started_pool.join Resque::Cluster.member.unregister if Resque::Cluster.member end # performed inside the run loop, must check for any distributed pool updates original_maintain_worker_count = instance_method(:maintain_worker_count) define_method(:maintain_worker_count) do cluster_update original_maintain_worker_count.bind(self).call end def quit log "Quiting ..." Process.kill(:TERM, Process.pid) end def cluster_update Resque::Cluster.member.perform if Resque::Cluster.member end def adjust_worker_counts(worker, number) over_adjustment = '' if @config[worker].to_i + number < 0 over_adjustment = "#{worker}:#{@config[worker].to_i + number}" @config[worker] = 0 else @config[worker] = @config[worker].to_i + number end over_adjustment end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
resque-cluster-0.2.2 | lib/resque/pool/patches.rb |
resque-cluster-0.2.1 | lib/resque/pool/patches.rb |
resque-cluster-0.2.0 | lib/resque/pool/patches.rb |