Sha256: 952b03536836f4824ef29c80a86479a8287aa0e895058d9ca8357d41c2c2513a

Contents?: true

Size: 925 Bytes

Versions: 2

Compression:

Stored size: 925 Bytes

Contents

require 'rush'

module Delayed
  module Workless
    module Scaler
      class Local < Base
        def self.executable_prefix
          if defined? Delayed::Compatibility.executable_prefix
            Delayed::Compatibility.executable_prefix
          else
            'script'
          end
        end

        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

        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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workless_revived-2.0.0 lib/workless/scalers/local.rb
workless_revived-1.2.5 lib/workless/scalers/local.rb