diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-17 13:48:53 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-17 13:48:53 +0200 |
commit | 5e431ff729a38dab4c7b02144168505ffba313da (patch) | |
tree | 6b3d8649147f7534fbcd2f9510dcf3df4d47a6da /lib | |
parent | 8e6f94c25bfaeec5ba64dcab8170499b2805fcfd (diff) | |
download | gitlab-ci-5e431ff729a38dab4c7b02144168505ffba313da.tar.gz |
Prevent build race condition for same project
Diffstat (limited to 'lib')
-rw-r--r-- | lib/runner.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/runner.rb b/lib/runner.rb index 112d40a..7b6ab4d 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -4,10 +4,8 @@ require 'timeout' class Runner include Sidekiq::Worker - TIMEOUT = 1800 attr_accessor :project, :build, :output - sidekiq_options queue: :runner def perform(build_id) @@ -15,7 +13,16 @@ class Runner @project = @build.project @output = '' - run + + if @project.no_running_builds? + run + else + run_later + end + end + + def run_later + Runner.perform_in(2.minutes, @build.id) end def initialize |