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



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

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



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

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

.upObject



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

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



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

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