Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
a6ab8a34
Commit
a6ab8a34
authored
Dec 14, 2016
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BuildQueueWorker for injecting redis-keys
parent
afea2df1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
app/models/ci/build.rb
app/models/ci/build.rb
+6
-0
app/workers/build_queue_worker.rb
app/workers/build_queue_worker.rb
+18
-0
lib/ci/api/helpers.rb
lib/ci/api/helpers.rb
+1
-0
No files found.
app/models/ci/build.rb
View file @
a6ab8a34
...
...
@@ -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
)
...
...
app/workers/build_queue_worker.rb
0 → 100644
View file @
a6ab8a34
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
lib/ci/api/helpers.rb
View file @
a6ab8a34
...
...
@@ -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?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment