Sha256: b0288f23a888abcb32301bc5e18c654dffe888e654fe564a0993e00e9c13ccbd
Contents?: true
Size: 1.44 KB
Versions: 6
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true module CI module Queue module Redis class Supervisor < Base def master? false end def total wait_for_master(timeout: config.queue_init_timeout) redis.get(key('total')).to_i end def build @build ||= CI::Queue::Redis::BuildRecord.new(self, redis, config) end def wait_for_workers wait_for_master(timeout: config.queue_init_timeout) yield if block_given? time_left = config.report_timeout time_left_with_no_workers = config.inactive_workers_timeout until exhausted? || time_left <= 0 || max_test_failed? || time_left_with_no_workers <= 0 time_left -= 1 sleep 1 if active_workers? time_left_with_no_workers = config.inactive_workers_timeout else time_left_with_no_workers -= 1 end yield if block_given? end puts "Aborting, it seems all workers died." if time_left_with_no_workers <= 0 exhausted? rescue CI::Queue::Redis::LostMaster false end private def active_workers? # if there are running jobs we assume there are still agents active redis.zrangebyscore(key('running'), CI::Queue.time_now.to_f - config.timeout, "+inf", limit: [0,1]).count > 0 end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems