Class: Delayed::Workless::Scaler::Local

Inherits:
Base
  • Object
show all
Defined in:
lib/workless/scalers/local.rb

Class Method Summary collapse

Methods inherited from Base

jobs

Class Method Details

.downObject



24
25
26
27
28
29
# File 'lib/workless/scalers/local.rb', line 24

def self.down
  if self.workers > 0 and jobs.count == 0
    Rush::Box.new[Rails.root].bash("#{executable_prefix}/delayed_job stop -i workless", :background => true)
  end
  true
end

.executable_prefixObject



8
9
10
11
12
13
14
# File 'lib/workless/scalers/local.rb', line 8

def self.executable_prefix
  if defined? Delayed::Compatibility.executable_prefix
    Delayed::Compatibility.executable_prefix
  else
    'script'
  end
end

.upObject



16
17
18
19
20
21
22
# File 'lib/workless/scalers/local.rb', line 16

def self.up
  if self.workers == 0
    Rush::Box.new[Rails.root].bash("#{executable_prefix}/delayed_job start -i workless", :background => true)
    sleep 1
  end
  true
end

.workersObject



31
32
33
# File 'lib/workless/scalers/local.rb', line 31

def self.workers
  Rush::Box.new.processes.filter(:cmdline => /delayed_job start -i workless|delayed_job.workless/).size
end