Class: RepositoryCheck::BatchWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/repository_check/batch_worker.rb

Constant Summary collapse

RUN_TIME =
3600

Instance Method Summary collapse

Instance Method Details

#performObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/workers/repository_check/batch_worker.rb', line 9

def perform
  start = Time.now
  
  # This loop will break after a little more than one hour ('a little
  # more' because `git fsck` may take a few minutes), or if it runs out of
  # projects to check. By default sidekiq-cron will start a new
  # RepositoryCheckWorker each hour so that as long as there are repositories to
  # check, only one (or two) will be checked at a time.
  project_ids.each do |project_id|
    break if Time.now - start >= RUN_TIME
    break unless current_settings.repository_checks_enabled
  
    next unless try_obtain_lease(project_id)
  
    SingleRepositoryWorker.new.perform(project_id)
  end
end