Class: Resque::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/resque/pool/patches.rb,
lib/resque/pool/cli_patches.rb

Overview

Resque Pool monkey patched methods for resque-pool

Defined Under Namespace

Modules: CLI

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject

add the running pool to distributed pool in order to manipulate it



7
8
9
10
11
12
13
14
15
16
# File 'lib/resque/pool/patches.rb', line 7

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

Instance Method Details

#adjust_worker_counts(worker, number) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/resque/pool/patches.rb', line 34

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

#cluster_updateObject



30
31
32
# File 'lib/resque/pool/patches.rb', line 30

def cluster_update
  Resque::Cluster.member.perform if Resque::Cluster.member
end

#quitObject



25
26
27
28
# File 'lib/resque/pool/patches.rb', line 25

def quit
  log "Quiting ..."
  Process.kill(:TERM, Process.pid)
end