Sha256: 88ec66086d5a2901362ebc513a9b2c72dd11c82367710d1998705bd5c6bc065c

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

module Cany::Recipes
  # This recipes installs Sidekiq
  #   "Simple, efficient, background processing in Ruby"
  # Sidekiq is registered as service and so automatically started.
  # @see http://sidekiq.org/ The official website for more information.
  # @note The recipe relies that 'sidekiq' is listed inside your Gemfile and
  #   therefore installed via the 'bundler' recipe.
  #
  # @!attribute queues
  #   @return [Array<String>, nil] An (optional) list of queue names sidekiq
  #     should listen on
  # @!attribute user
  #   @return [String, nil] The user name as which the sidekiq process should
  #      executed
  # @!attribute group
  #   @return [String, nil] The group name as which the sidekiq process should
  #      executed
  class Sidekiq < Cany::Recipe
    register_as :sidekiq

    attr_accessor :queues
    attr_accessor :user, :group

    def initialize(*args)
      @queues = []
      @user = 'www-data'
      @group = 'www-data'
      super
    end

    class DSL < Cany::Recipe::DSL
      def queue(name)
        @recipe.queues << name
      end
      delegate :user, :group
    end

    def binary
      install_service name, %W(/usr/bin/#{spec.name} sidekiq) + sidekiq_args, user: user, group: group
      inner.binary
    end

    def sidekiq_args
      args = %w(--environment production)
      queues.each do |queue|
        args << '--queue'
        args << queue.to_s
      end
      args
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cany-0.5.7 lib/cany/recipes/sidekiq.rb
cany-0.5.6 lib/cany/recipes/sidekiq.rb
cany-0.5.5 lib/cany/recipes/sidekiq.rb