Class: GemStashUpdateWorker
- Inherits:
-
Object
- Object
- GemStashUpdateWorker
- Includes:
- Sidekiq::Worker
- Defined in:
- app/workers/gem_stash_update_worker.rb
Instance Method Summary collapse
Instance Method Details
#perform ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/workers/gem_stash_update_worker.rb', line 8 def perform begin TerminalBuild.stash_worker_lock.lock do while TerminalBuild.stash_counter.getset(0) > 0 update_stash! end end rescue Redis::Lock::LockTimeout => e Sidekiq::Logging.logger.warn "Lock timeout." # To avoid excessive cpu burning but still ensure robust updates GemStashUpdateWorker.perform_in 1.minute end end |
#update_stash! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/workers/gem_stash_update_worker.rb', line 23 def update_stash! builds = TerminalBuild.all stasher = GemStasher.new Sidekiq::Logging.logger, Rails.root.join("public/gems") stasher.maintain_cache builds.map(&:path) stasher.update_index TerminalBuild.transaction do builds.each do |build| begin build.gems_ready = true build.save! rescue => e Sidekiq::Logging.logger.warn "error occured during update of build #{build.id}: #{e}" end end end end |