Skip to content

Commit 66ecfa7

Browse files
committed
Merge branch 'sidekiq'
2 parents 7bfd38e + 9773ccc commit 66ecfa7

36 files changed

+147
-196
lines changed

Gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ gem "acts-as-taggable-on", "2.3.3"
8181
gem "draper", "~> 0.18.0"
8282

8383
# Background jobs
84-
gem "resque", git: "https://github.com/gitlabhq/resque.git", ref: "9ef4700306dd946a3ac000612428967ce0c32213"
85-
gem 'resque_mailer'
84+
gem 'slim'
85+
gem 'sinatra', :require => nil
86+
gem 'sidekiq', '2.6.4'
8687

8788
# HTTP requests
8889
gem "httparty"
@@ -157,7 +158,6 @@ group :test do
157158
gem "simplecov", require: false
158159
gem "shoulda-matchers", "1.3.0"
159160
gem 'email_spec'
160-
gem 'resque_spec'
161161
gem "webmock"
162162
gem 'test_after_commit'
163163
end

Gemfile.lock

+19-21
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,6 @@ GIT
5454
specs:
5555
raphael-rails (2.1.0)
5656

57-
GIT
58-
remote: https://github.com/gitlabhq/resque.git
59-
revision: 9ef4700306dd946a3ac000612428967ce0c32213
60-
ref: 9ef4700306dd946a3ac000612428967ce0c32213
61-
specs:
62-
resque (2.0.0.pre.1)
63-
json
64-
redis-namespace (~> 1.0)
65-
sinatra (>= 0.9.2)
66-
vegas (~> 0.1.2)
67-
6857
GIT
6958
remote: https://github.com/jonleighton/poltergeist.git
7059
revision: 5c2e092001074a8cf09f332d3714e9ba150bc8ca
@@ -132,6 +121,9 @@ GEM
132121
carrierwave (0.7.1)
133122
activemodel (>= 3.2.0)
134123
activesupport (>= 3.2.0)
124+
celluloid (0.12.4)
125+
facter (>= 1.6.12)
126+
timers (>= 1.0.0)
135127
charlock_holmes (0.6.9)
136128
childprocess (0.3.6)
137129
ffi (~> 1.0, >= 1.0.6)
@@ -150,6 +142,7 @@ GEM
150142
coffee-script-source (1.4.0)
151143
colored (1.2)
152144
colorize (0.5.8)
145+
connection_pool (1.0.0)
153146
crack (0.3.1)
154147
daemons (1.1.9)
155148
devise (2.1.2)
@@ -169,6 +162,7 @@ GEM
169162
eventmachine (1.0.0)
170163
execjs (1.4.0)
171164
multi_json (~> 1.0)
165+
facter (1.6.17)
172166
factory_girl (4.1.0)
173167
activesupport (>= 3.0.0)
174168
factory_girl_rails (4.1.0)
@@ -370,11 +364,6 @@ GEM
370364
redis (3.0.2)
371365
redis-namespace (1.2.1)
372366
redis (~> 3.0.0)
373-
resque_mailer (2.1.0)
374-
actionmailer (~> 3.0)
375-
resque_spec (0.12.5)
376-
resque (>= 1.19.0)
377-
rspec (>= 2.5.0)
378367
rspec (2.12.0)
379368
rspec-core (~> 2.12.0)
380369
rspec-expectations (~> 2.12.0)
@@ -412,6 +401,12 @@ GEM
412401
sexp_processor (4.1.3)
413402
shoulda-matchers (1.3.0)
414403
activesupport (>= 3.0.0)
404+
sidekiq (2.6.4)
405+
celluloid (~> 0.12.0)
406+
connection_pool (~> 1.0)
407+
multi_json (~> 1)
408+
redis (~> 3)
409+
redis-namespace
415410
simplecov (0.7.1)
416411
multi_json (~> 1.0)
417412
simplecov-html (~> 0.7.1)
@@ -421,6 +416,9 @@ GEM
421416
rack-protection (~> 1.2)
422417
tilt (~> 1.3, >= 1.3.3)
423418
six (0.2.0)
419+
slim (1.3.6)
420+
temple (~> 0.5.5)
421+
tilt (~> 1.3.3)
424422
slop (3.3.3)
425423
spinach (0.5.2)
426424
colorize
@@ -435,6 +433,7 @@ GEM
435433
rack (~> 1.0)
436434
tilt (~> 1.1, != 1.3.0)
437435
stamp (0.3.0)
436+
temple (0.5.5)
438437
test_after_commit (0.0.1)
439438
therubyracer (0.10.2)
440439
libv8 (~> 3.3.10)
@@ -444,6 +443,7 @@ GEM
444443
rack (>= 1.0.0)
445444
thor (0.16.0)
446445
tilt (1.3.3)
446+
timers (1.0.2)
447447
treetop (1.4.12)
448448
polyglot
449449
polyglot (>= 0.3.1)
@@ -455,8 +455,6 @@ GEM
455455
kgio (~> 2.6)
456456
rack
457457
raindrops (~> 0.7)
458-
vegas (0.1.11)
459-
rack (>= 1.0.0)
460458
virtus (0.5.2)
461459
backports (~> 2.6.1)
462460
warden (1.2.1)
@@ -534,17 +532,17 @@ DEPENDENCIES
534532
rb-fsevent
535533
rb-inotify
536534
redcarpet (~> 2.2.2)
537-
resque!
538-
resque_mailer
539-
resque_spec
540535
rspec-rails
541536
sass-rails (~> 3.2.5)
542537
sdoc
543538
seed-fu
544539
settingslogic
545540
shoulda-matchers (= 1.3.0)
541+
sidekiq (= 2.6.4)
546542
simplecov
543+
sinatra
547544
six
545+
slim
548546
spinach-rails
549547
stamp
550548
test_after_commit

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
web: bundle exec rails s -p $PORT
2-
worker: bundle exec rake environment resque:work QUEUE=* VVERBOSE=1
2+
worker: bundle exec sidekiq -q post_receive,mailer,system_hook,common,default

app/controllers/admin/dashboard_controller.rb

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ def index
33
@projects = Project.order("created_at DESC").limit(10)
44
@users = User.order("created_at DESC").limit(10)
55

6-
@resque_accessible = true
7-
@workers = Resque.workers
8-
@pending_jobs = Resque.size(:post_receive)
9-
106
rescue Redis::InheritedError
117
@resque_accessible = false
128
end

app/mailers/notify.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Notify < ActionMailer::Base
2-
include Resque::Mailer
2+
33
add_template_helper ApplicationHelper
44
add_template_helper GitlabMarkdownHelper
55

app/models/project.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def items_for entity
251251

252252
def send_move_instructions
253253
self.users_projects.each do |member|
254-
Notify.project_was_moved_email(member.id).deliver
254+
Notify.delay.project_was_moved_email(member.id)
255255
end
256256
end
257257

app/models/system_hook.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def self.all_hooks_fire(data)
1919
end
2020

2121
def async_execute(data)
22-
Resque.enqueue(SystemHookWorker, id, data)
22+
Sidekiq::Client.enqueue(SystemHookWorker, id, data)
2323
end
2424
end

app/observers/issue_observer.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class IssueObserver < ActiveRecord::Observer
33

44
def after_create(issue)
55
if issue.assignee && issue.assignee != current_user
6-
Notify.new_issue_email(issue.id).deliver
6+
Notify.delay.new_issue_email(issue.id)
77
end
88
end
99

@@ -16,7 +16,7 @@ def after_update(issue)
1616
if status
1717
Note.create_status_change_note(issue, current_user, status)
1818
[issue.author, issue.assignee].compact.each do |recipient|
19-
Notify.issue_status_changed_email(recipient.id, issue.id, status, current_user.id).deliver
19+
Notify.delay.issue_status_changed_email(recipient.id, issue.id, status, current_user.id)
2020
end
2121
end
2222
end
@@ -27,7 +27,7 @@ def send_reassigned_email(issue)
2727
recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id && id != current_user.id }
2828

2929
recipient_ids.each do |recipient_id|
30-
Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was).deliver
30+
Notify.delay.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was)
3131
end
3232
end
3333
end

app/observers/merge_request_observer.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class MergeRequestObserver < ActiveRecord::Observer
33

44
def after_create(merge_request)
55
if merge_request.assignee && merge_request.assignee != current_user
6-
Notify.new_merge_request_email(merge_request.id).deliver
6+
Notify.delay.new_merge_request_email(merge_request.id)
77
end
88
end
99

@@ -25,7 +25,7 @@ def send_reassigned_email(merge_request)
2525
recipients_ids.delete current_user.id
2626

2727
recipients_ids.each do |recipient_id|
28-
Notify.reassigned_merge_request_email(recipient_id, merge_request.id, merge_request.assignee_id_was).deliver
28+
Notify.delay.reassigned_merge_request_email(recipient_id, merge_request.id, merge_request.assignee_id_was)
2929
end
3030
end
3131
end

app/observers/note_observer.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def send_notify_mails(note)
1111
notify_team(note)
1212
elsif note.notify_author
1313
# Notify only author of resource
14-
Notify.note_commit_email(note.commit_author.id, note.id).deliver
14+
Notify.delay.note_commit_email(note.commit_author.id, note.id)
1515
else
1616
# Otherwise ignore it
1717
nil
@@ -26,7 +26,7 @@ def notify_team(note)
2626

2727
if Notify.respond_to? notify_method
2828
team_without_note_author(note).map do |u|
29-
Notify.send(notify_method, u.id, note.id).deliver
29+
Notify.delay.send(notify_method, u.id, note.id)
3030
end
3131
end
3232
end

app/observers/user_observer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class UserObserver < ActiveRecord::Observer
22
def after_create(user)
33
log_info("User \"#{user.name}\" (#{user.email}) was created")
44

5-
Notify.new_user_email(user.id, user.password).deliver
5+
Notify.delay.new_user_email(user.id, user.password)
66
end
77

88
def after_destroy user

app/observers/users_project_observer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class UsersProjectObserver < ActiveRecord::Observer
22
def after_commit(users_project)
33
return if users_project.destroyed?
4-
Notify.project_access_granted_email(users_project.id).deliver
4+
Notify.delay.project_access_granted_email(users_project.id)
55
end
66

77
def after_create(users_project)

app/views/admin/dashboard/index.html.haml

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,28 @@
11
.admin_dash.row
2-
.span3
2+
.span4
33
.ui-box
44
%h5.title Projects
55
.data.padded
66
= link_to admin_projects_path do
77
%h1= Project.count
88
%hr
99
= link_to 'New Project', new_project_path, class: "btn small"
10-
.span3
10+
.span4
1111
.ui-box
1212
%h5.title Groups
1313
.data.padded
1414
= link_to admin_groups_path do
1515
%h1= Group.count
1616
%hr
1717
= link_to 'New Group', new_admin_group_path, class: "btn small"
18-
.span3
18+
.span4
1919
.ui-box
2020
%h5.title Users
2121
.data.padded
2222
= link_to admin_users_path do
2323
%h1= User.count
2424
%hr
2525
= link_to 'New User', new_admin_user_path, class: "btn small"
26-
.span3
27-
.ui-box
28-
%h5.title
29-
Resque Workers
30-
.data.padded
31-
- if @resque_accessible
32-
= link_to admin_resque_path do
33-
%h1{class: @workers.present? ? "cgreen" : "cred"}
34-
= @workers.count
35-
%hr
36-
%p
37-
%strong{class: @pending_jobs > 0 ? "cred" : "cgreen"}
38-
#{@pending_jobs} post receive jobs waiting
39-
- else
40-
= link_to admin_resque_path do
41-
%h1.cdark ?
42-
%hr
43-
%p
44-
%strong Resque status unknown
4526

4627
.row
4728
.span6

app/views/admin/resque/show.html.haml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%h3.page_title Resque
1+
%h3.page_title Background Jobs
22
%br
33
.ui-box
4-
%iframe{src: resque_path, width: '100%', height: 600, style: "border: none"}
4+
%iframe{src: sidekiq_path, width: '100%', height: 900, style: "border: none"}

app/views/layouts/admin.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
= nav_link(controller: :hooks) do
2020
= link_to "Hooks", admin_hooks_path
2121
= nav_link(controller: :resque) do
22-
= link_to "Resque", admin_resque_path
22+
= link_to "Background Jobs", admin_resque_path
2323

2424
.content= yield

app/workers/post_receive.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
class PostReceive
2-
@queue = :post_receive
2+
include Sidekiq::Worker
33

4-
def self.perform(repo_path, oldrev, newrev, ref, identifier)
4+
sidekiq_options queue: :post_receive
5+
6+
def perform(repo_path, oldrev, newrev, ref, identifier)
57
repo_path.gsub!(Gitlab.config.gitolite.repos_path.to_s, "")
68
repo_path.gsub!(/.git$/, "")
79
repo_path.gsub!(/^\//, "")

app/workers/system_hook_worker.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
class SystemHookWorker
2-
@queue = :system_hook
2+
include Sidekiq::Worker
33

4-
def self.perform(hook_id, data)
4+
sidekiq_options queue: :system_hook
5+
6+
def perform(hook_id, data)
57
SystemHook.find(hook_id).execute data
68
end
79
end

config/initializers/4_resque.rb

-29
This file was deleted.

0 commit comments

Comments
 (0)