Commit 71bd9568669d18bc04c551a603a04af2ea99328c
1 parent
c7bb3a1f
Exists in
master
and in
4 other branches
email via sidekiq. start and stop rake tasks
Showing
15 changed files
with
36 additions
and
46 deletions
Show diff stats
Gemfile
Gemfile.lock
... | ... | @@ -407,10 +407,6 @@ GEM |
407 | 407 | multi_json (~> 1) |
408 | 408 | redis (~> 3) |
409 | 409 | redis-namespace |
410 | - sidekiq_mailer (0.0.4) | |
411 | - actionmailer (~> 3.0) | |
412 | - activesupport (~> 3.0) | |
413 | - sidekiq (~> 2.3) | |
414 | 410 | simplecov (0.7.1) |
415 | 411 | multi_json (~> 1.0) |
416 | 412 | simplecov-html (~> 0.7.1) |
... | ... | @@ -543,7 +539,6 @@ DEPENDENCIES |
543 | 539 | settingslogic |
544 | 540 | shoulda-matchers (= 1.3.0) |
545 | 541 | sidekiq (= 2.6.4) |
546 | - sidekiq_mailer | |
547 | 542 | simplecov |
548 | 543 | sinatra |
549 | 544 | six | ... | ... |
Procfile
app/mailers/notify.rb
app/models/project.rb
... | ... | @@ -251,7 +251,7 @@ class Project < ActiveRecord::Base |
251 | 251 | |
252 | 252 | def send_move_instructions |
253 | 253 | self.users_projects.each do |member| |
254 | - Notify.project_was_moved_email(member.id).deliver | |
254 | + Notify.delay.project_was_moved_email(member.id) | |
255 | 255 | end |
256 | 256 | end |
257 | 257 | ... | ... |
app/observers/issue_observer.rb
... | ... | @@ -3,7 +3,7 @@ class IssueObserver < ActiveRecord::Observer |
3 | 3 | |
4 | 4 | def after_create(issue) |
5 | 5 | if issue.assignee && issue.assignee != current_user |
6 | - Notify.new_issue_email(issue.id).deliver | |
6 | + Notify.delay.new_issue_email(issue.id) | |
7 | 7 | end |
8 | 8 | end |
9 | 9 | |
... | ... | @@ -16,7 +16,7 @@ class IssueObserver < ActiveRecord::Observer |
16 | 16 | if status |
17 | 17 | Note.create_status_change_note(issue, current_user, status) |
18 | 18 | [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) | |
20 | 20 | end |
21 | 21 | end |
22 | 22 | end |
... | ... | @@ -27,7 +27,7 @@ class IssueObserver < ActiveRecord::Observer |
27 | 27 | recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id && id != current_user.id } |
28 | 28 | |
29 | 29 | 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) | |
31 | 31 | end |
32 | 32 | end |
33 | 33 | end | ... | ... |
app/observers/merge_request_observer.rb
... | ... | @@ -3,7 +3,7 @@ class MergeRequestObserver < ActiveRecord::Observer |
3 | 3 | |
4 | 4 | def after_create(merge_request) |
5 | 5 | 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) | |
7 | 7 | end |
8 | 8 | end |
9 | 9 | |
... | ... | @@ -25,7 +25,7 @@ class MergeRequestObserver < ActiveRecord::Observer |
25 | 25 | recipients_ids.delete current_user.id |
26 | 26 | |
27 | 27 | 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) | |
29 | 29 | end |
30 | 30 | end |
31 | 31 | end | ... | ... |
app/observers/note_observer.rb
... | ... | @@ -11,7 +11,7 @@ class NoteObserver < ActiveRecord::Observer |
11 | 11 | notify_team(note) |
12 | 12 | elsif note.notify_author |
13 | 13 | # 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) | |
15 | 15 | else |
16 | 16 | # Otherwise ignore it |
17 | 17 | nil |
... | ... | @@ -26,7 +26,7 @@ class NoteObserver < ActiveRecord::Observer |
26 | 26 | |
27 | 27 | if Notify.respond_to? notify_method |
28 | 28 | 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) | |
30 | 30 | end |
31 | 31 | end |
32 | 32 | end | ... | ... |
app/observers/user_observer.rb
... | ... | @@ -2,7 +2,7 @@ class UserObserver < ActiveRecord::Observer |
2 | 2 | def after_create(user) |
3 | 3 | log_info("User \"#{user.name}\" (#{user.email}) was created") |
4 | 4 | |
5 | - Notify.new_user_email(user.id, user.password).deliver | |
5 | + Notify.delay.new_user_email(user.id, user.password) | |
6 | 6 | end |
7 | 7 | |
8 | 8 | def after_destroy user | ... | ... |
app/observers/users_project_observer.rb
1 | 1 | class UsersProjectObserver < ActiveRecord::Observer |
2 | 2 | def after_commit(users_project) |
3 | 3 | 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) | |
5 | 5 | end |
6 | 6 | |
7 | 7 | def after_create(users_project) | ... | ... |
config/routes.rb
... | ... | @@ -12,7 +12,7 @@ Gitlab::Application.routes.draw do |
12 | 12 | |
13 | 13 | constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } |
14 | 14 | constraints constraint do |
15 | - mount Sidekiq::Web, at: "/admin/workers", as: :sidekiq | |
15 | + mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq | |
16 | 16 | end |
17 | 17 | |
18 | 18 | # Enable Grack support | ... | ... |
lib/tasks/resque.rake
... | ... | @@ -1,23 +0,0 @@ |
1 | -require 'resque/tasks' | |
2 | - | |
3 | -namespace :resque do | |
4 | - task setup: :environment do | |
5 | - #Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } | |
6 | - end | |
7 | - | |
8 | - desc "Resque | kill all workers (using -QUIT), god will take care of them" | |
9 | - task :stop_workers => :environment do | |
10 | - #pids = Array.new | |
11 | - | |
12 | - #Resque.workers.each do |worker| | |
13 | - #pids << worker.to_s.split(/:/).second | |
14 | - #end | |
15 | - | |
16 | - #if pids.size > 0 | |
17 | - #system("kill -QUIT #{pids.join(' ')}") | |
18 | - #end | |
19 | - end | |
20 | -end | |
21 | - | |
22 | -desc "Alias for resque:work (To run workers on Heroku)" | |
23 | -task "jobs:work" => "resque:work" |
... | ... | @@ -0,0 +1,23 @@ |
1 | +namespace :sidekiq do | |
2 | + desc "GITLAB | Stop sidekiq" | |
3 | + task :stop do | |
4 | + run "bundle exec sidekiqctl stop #{pidfile}" | |
5 | + end | |
6 | + | |
7 | + desc "GITLAB | Start sidekiq" | |
8 | + task :start do | |
9 | + run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,common,default -e #{rails_env} -P #{pidfile} >> #{root_path}/log/sidekiq.log 2>&1 &" | |
10 | + end | |
11 | + | |
12 | + def root_path | |
13 | + @root_path ||= File.join(File.expand_path(File.dirname(__FILE__)), "../..") | |
14 | + end | |
15 | + | |
16 | + def pidfile | |
17 | + "#{root_path}/tmp/pids/sidekiq.pid" | |
18 | + end | |
19 | + | |
20 | + def rails_env | |
21 | + ENV['RAILS_ENV'] || "production" | |
22 | + end | |
23 | +end | ... | ... |
resque.sh
resque_dev.sh