Sha256: 4b8df053e9cc377af8577c8bd7e8dc1d58c3909b698baf8f76d282e3126750ba

Contents?: true

Size: 900 Bytes

Versions: 4

Compression:

Stored size: 900 Bytes

Contents

require 'roo_on_rails/checks/base'

module RooOnRails
  module Checks
    module Sidekiq
      class Sidekiq < Base
        WORKER_PROCFILE_LINE = 'worker: bundle exec roo_on_rails sidekiq'.freeze

        def intro
          'Checking Sidekiq Setup...'
        end

        def call
          unless ENV.fetch('SIDEKIQ_ENABLED', 'true').to_s =~ /\A(YES|TRUE|ON|1)\Z/i
            pass 'SIDEKIQ_ENABLED is set to false'
            return
          end
          check_for_procfile
        end

        def fix
          output = File.exist?('Procfile') ? "\n#{WORKER_PROCFILE_LINE}" : WORKER_PROCFILE_LINE
          File.open('Procfile', 'a') { |f| f.write(output) }
        end

        def check_for_procfile
          return if File.exist?('Procfile') && File.read('Procfile').include?('worker')
          fail! "No Procfile found with a 'worker' command"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
roo_on_rails-1.10.0 lib/roo_on_rails/checks/sidekiq/sidekiq.rb
roo_on_rails-1.9.0 lib/roo_on_rails/checks/sidekiq/sidekiq.rb
roo_on_rails-1.8.1 lib/roo_on_rails/checks/sidekiq/sidekiq.rb
roo_on_rails-1.8.0 lib/roo_on_rails/checks/sidekiq/sidekiq.rb