Skip to content

Commit 71bd956

Browse files
committed
email via sidekiq. start and stop rake tasks
1 parent c7bb3a1 commit 71bd956

15 files changed

+36
-46
lines changed

Gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ gem "draper", "~> 0.18.0"
8484
gem 'slim'
8585
gem 'sinatra', :require => nil
8686
gem 'sidekiq', '2.6.4'
87-
gem 'sidekiq_mailer'
8887

8988
# HTTP requests
9089
gem "httparty"

Gemfile.lock

-5
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,6 @@ GEM
407407
multi_json (~> 1)
408408
redis (~> 3)
409409
redis-namespace
410-
sidekiq_mailer (0.0.4)
411-
actionmailer (~> 3.0)
412-
activesupport (~> 3.0)
413-
sidekiq (~> 2.3)
414410
simplecov (0.7.1)
415411
multi_json (~> 1.0)
416412
simplecov-html (~> 0.7.1)
@@ -543,7 +539,6 @@ DEPENDENCIES
543539
settingslogic
544540
shoulda-matchers (= 1.3.0)
545541
sidekiq (= 2.6.4)
546-
sidekiq_mailer
547542
simplecov
548543
sinatra
549544
six

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 sidekiq -q post_receive,mailer,system_hook,common
2+
worker: bundle exec rake sidekiq:start

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 Sidekiq::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/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)

config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
1414
constraints constraint do
15-
mount Sidekiq::Web, at: "/admin/workers", as: :sidekiq
15+
mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq
1616
end
1717

1818
# Enable Grack support

lib/tasks/resque.rake

-23
This file was deleted.

lib/tasks/sidekiq.rake

+23
Original file line numberDiff line numberDiff line change
@@ -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

-2
This file was deleted.

resque_dev.sh

-2
This file was deleted.

0 commit comments

Comments
 (0)