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



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

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

.executable_prefixObject



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

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

.upObject



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

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

.workersObject



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

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