Commit 8a65229b3548a421ca6e7c41a819b40d50f7e162
1 parent
639b0a87
Exists in
master
and in
4 other branches
Updates project to process web hooks async via sidekiq.
A new queue of "project_web_hook" is used to process web hooks asynchronously, allowing each to succeed/fail (and be retried) independently. (Basically, project web hooks now process the same as system hooks.)
Showing
5 changed files
with
16 additions
and
3 deletions
Show diff stats
Procfile
app/models/project.rb
@@ -340,7 +340,7 @@ class Project < ActiveRecord::Base | @@ -340,7 +340,7 @@ class Project < ActiveRecord::Base | ||
340 | end | 340 | end |
341 | 341 | ||
342 | def execute_hooks(data) | 342 | def execute_hooks(data) |
343 | - hooks.each { |hook| hook.execute(data) } | 343 | + hooks.each { |hook| hook.async_execute(data) } |
344 | end | 344 | end |
345 | 345 | ||
346 | def execute_services(data) | 346 | def execute_services(data) |
app/models/web_hook.rb
@@ -34,4 +34,8 @@ class WebHook < ActiveRecord::Base | @@ -34,4 +34,8 @@ class WebHook < ActiveRecord::Base | ||
34 | basic_auth: {username: parsed_url.user, password: parsed_url.password}) | 34 | basic_auth: {username: parsed_url.user, password: parsed_url.password}) |
35 | end | 35 | end |
36 | end | 36 | end |
37 | + | ||
38 | + def async_execute(data) | ||
39 | + Sidekiq::Client.enqueue(ProjectWebHookWorker, id, data) | ||
40 | + end | ||
37 | end | 41 | end |
lib/tasks/sidekiq.rake
@@ -6,7 +6,7 @@ namespace :sidekiq do | @@ -6,7 +6,7 @@ namespace :sidekiq do | ||
6 | 6 | ||
7 | desc "GITLAB | Start sidekiq" | 7 | desc "GITLAB | Start sidekiq" |
8 | task :start do | 8 | task :start do |
9 | - run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,common,default -e #{Rails.env} -P #{pidfile} >> #{Rails.root.join("log", "sidekiq.log")} 2>&1 &" | 9 | + run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,common,default -e #{Rails.env} -P #{pidfile} >> #{Rails.root.join("log", "sidekiq.log")} 2>&1 &" |
10 | end | 10 | end |
11 | 11 | ||
12 | def pidfile | 12 | def pidfile |