Sha256: 369cb2586d909f614e9b3b2f507a114e2afcd1b11d7b181bf99fbf620ef753ca

Contents?: true

Size: 946 Bytes

Versions: 4

Compression:

Stored size: 946 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 self.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 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

        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

4 entries across 4 versions & 2 rubygems

Version Path
workless_revived-1.2.4.2 lib/workless/scalers/local.rb
workless_revived-1.2.4 lib/workless/scalers/local.rb
workless-1.2.3 lib/workless/scalers/local.rb
workless-1.2.2 lib/workless/scalers/local.rb