summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-17 13:48:53 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-17 13:48:53 +0200
commit5e431ff729a38dab4c7b02144168505ffba313da (patch)
tree6b3d8649147f7534fbcd2f9510dcf3df4d47a6da /lib
parent8e6f94c25bfaeec5ba64dcab8170499b2805fcfd (diff)
downloadgitlab-ci-5e431ff729a38dab4c7b02144168505ffba313da.tar.gz
Prevent build race condition for same project
Diffstat (limited to 'lib')
-rw-r--r--lib/runner.rb13
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