Add BuildQueueWorker for injecting redis-keys
This commit is contained in:
parent
afea2df151
commit
a6ab8a3409
3 changed files with 25 additions and 0 deletions
|
@ -81,6 +81,12 @@ module Ci
|
|||
end
|
||||
|
||||
state_machine :status do
|
||||
after_transition any => [:pending] do |build|
|
||||
build.run_after_commit do
|
||||
BuildQueueWorker.perform_async(id)
|
||||
end
|
||||
end
|
||||
|
||||
after_transition pending: :running do |build|
|
||||
build.run_after_commit do
|
||||
BuildHooksWorker.perform_async(id)
|
||||
|
|
18
app/workers/build_queue_worker.rb
Normal file
18
app/workers/build_queue_worker.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
class BuildQueueWorker
|
||||
include Sidekiq::Worker
|
||||
include BuildQueue
|
||||
|
||||
def perform(build_id)
|
||||
Ci::Build.find_by(id: build_id).try do |build|
|
||||
project.runners.select do |runner|
|
||||
if runner.can_pick?(build)
|
||||
# Inject last_update into Redis
|
||||
Gitlab::Redis.with do |redis]
|
||||
new_update = Time.new.inspect
|
||||
redis.set(current_runner_redis_key, new_update, ex: 60.minutes)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -62,6 +62,7 @@ module Ci
|
|||
|
||||
def current_runner_redis_key
|
||||
@runner_redis_key ||= "#{current_runner.token}_#{current_runner.tag_list}"
|
||||
end
|
||||
|
||||
def get_runner_version_from_params
|
||||
return unless params["info"].present?
|
||||
|
|
Loading…
Reference in a new issue