Commit a20681c0 authored by Kim "BKC" Carlbäcker's avatar Kim "BKC" Carlbäcker

Update Runners in a Service

parent e1795443
module Ci
class UpdateBuildQueueService < BaseService
def execute(build)
build.project.runners.select do |runner|
if runner.can_pick?(build)
runner.tick_update
end
end
end
end
end
...@@ -4,22 +4,8 @@ class BuildQueueWorker ...@@ -4,22 +4,8 @@ class BuildQueueWorker
def perform(build_id) def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build| Ci::Build.find_by(id: build_id).try do |build|
build.project.runners.select do |runner| UpdateBuildQueueService.new(build)
if runner.can_pick?(build)
# Inject last_update into Redis
Gitlab::Redis.with do |redis|
new_update = Time.new.inspect
redis.set(runner_redis_key(runner), new_update, ex: 60.minutes)
end
end
end
end end
end end
private
def runner_redis_key(runner)
"#{runner.token}_#{runner.tag_list}"
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment