Sha256: ff4a4b9630390eddcd34f34bd2d43419de4ed4880705a7731a18e856763c8f88

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module Capistrano
  module Sidekiq::Helpers

    def sidekiq_require
      if fetch(:sidekiq_require)
        "--require #{fetch(:sidekiq_require)}"
      end
    end

    def sidekiq_config
      if fetch(:sidekiq_config)
        "--config #{fetch(:sidekiq_config)}"
      end
    end

    def sidekiq_concurrency
      if fetch(:sidekiq_concurrency)
        "--concurrency #{fetch(:sidekiq_concurrency)}"
      end
    end

    def sidekiq_queues
      Array(fetch(:sidekiq_queue)).map do |queue|
        "--queue #{queue}"
      end.join(' ')
    end

    def sidekiq_logfile
      fetch(:sidekiq_log)
    end

    def switch_user(role)
      su_user = sidekiq_user(role)
      if su_user == role.user
        yield
      else
        as su_user do
          yield
        end
      end
    end

    def sidekiq_user(role = nil)
      if role.nil?
        fetch(:sidekiq_user)
      else
        properties = role.properties
        properties.fetch(:sidekiq_user) || # local property for sidekiq only
          fetch(:sidekiq_user) ||
          properties.fetch(:run_as) || # global property across multiple capistrano gems
          role.user
      end
    end

    def expanded_bundle_path
      backend.capture(:echo, SSHKit.config.command_map[:bundle]).strip
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-sidekiq-2.2.0 lib/capistrano/sidekiq/helpers.rb
capistrano-sidekiq-2.1.0 lib/capistrano/sidekiq/helpers.rb