diff options
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | Gemfile.lock | 5 | ||||
-rw-r--r-- | Procfile | 2 | ||||
-rw-r--r-- | app/mailers/notify.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | app/observers/issue_observer.rb | 6 | ||||
-rw-r--r-- | app/observers/merge_request_observer.rb | 4 | ||||
-rw-r--r-- | app/observers/note_observer.rb | 4 | ||||
-rw-r--r-- | app/observers/user_observer.rb | 2 | ||||
-rw-r--r-- | app/observers/users_project_observer.rb | 2 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | lib/tasks/resque.rake | 23 | ||||
-rw-r--r-- | lib/tasks/sidekiq.rake | 23 | ||||
-rwxr-xr-x | resque.sh | 2 | ||||
-rwxr-xr-x | resque_dev.sh | 2 |
15 files changed, 36 insertions, 46 deletions
@@ -84,7 +84,6 @@ gem "draper", "~> 0.18.0" gem 'slim' gem 'sinatra', :require => nil gem 'sidekiq', '2.6.4' -gem 'sidekiq_mailer' # HTTP requests gem "httparty" diff --git a/Gemfile.lock b/Gemfile.lock index b9008340d99..8fba310d4eb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -407,10 +407,6 @@ GEM multi_json (~> 1) redis (~> 3) redis-namespace - sidekiq_mailer (0.0.4) - actionmailer (~> 3.0) - activesupport (~> 3.0) - sidekiq (~> 2.3) simplecov (0.7.1) multi_json (~> 1.0) simplecov-html (~> 0.7.1) @@ -543,7 +539,6 @@ DEPENDENCIES settingslogic shoulda-matchers (= 1.3.0) sidekiq (= 2.6.4) - sidekiq_mailer simplecov sinatra six @@ -1,2 +1,2 @@ web: bundle exec rails s -p $PORT -worker: bundle exec sidekiq -q post_receive,mailer,system_hook,common +worker: bundle exec rake sidekiq:start diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 87d3e4b204e..c672940a05e 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -1,5 +1,5 @@ class Notify < ActionMailer::Base - include Sidekiq::Mailer + add_template_helper ApplicationHelper add_template_helper GitlabMarkdownHelper diff --git a/app/models/project.rb b/app/models/project.rb index 702f4b2bf81..32b951349a9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -251,7 +251,7 @@ class Project < ActiveRecord::Base def send_move_instructions self.users_projects.each do |member| - Notify.project_was_moved_email(member.id).deliver + Notify.delay.project_was_moved_email(member.id) end end diff --git a/app/observers/issue_observer.rb b/app/observers/issue_observer.rb index 131336be8b6..262d0f892c4 100644 --- a/app/observers/issue_observer.rb +++ b/app/observers/issue_observer.rb @@ -3,7 +3,7 @@ class IssueObserver < ActiveRecord::Observer def after_create(issue) if issue.assignee && issue.assignee != current_user - Notify.new_issue_email(issue.id).deliver + Notify.delay.new_issue_email(issue.id) end end @@ -16,7 +16,7 @@ class IssueObserver < ActiveRecord::Observer if status Note.create_status_change_note(issue, current_user, status) [issue.author, issue.assignee].compact.each do |recipient| - Notify.issue_status_changed_email(recipient.id, issue.id, status, current_user.id).deliver + Notify.delay.issue_status_changed_email(recipient.id, issue.id, status, current_user.id) end end end @@ -27,7 +27,7 @@ class IssueObserver < ActiveRecord::Observer recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id && id != current_user.id } recipient_ids.each do |recipient_id| - Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was).deliver + Notify.delay.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was) end end end diff --git a/app/observers/merge_request_observer.rb b/app/observers/merge_request_observer.rb index c4040f1542d..6d3c2bdd186 100644 --- a/app/observers/merge_request_observer.rb +++ b/app/observers/merge_request_observer.rb @@ -3,7 +3,7 @@ class MergeRequestObserver < ActiveRecord::Observer def after_create(merge_request) if merge_request.assignee && merge_request.assignee != current_user - Notify.new_merge_request_email(merge_request.id).deliver + Notify.delay.new_merge_request_email(merge_request.id) end end @@ -25,7 +25,7 @@ class MergeRequestObserver < ActiveRecord::Observer recipients_ids.delete current_user.id recipients_ids.each do |recipient_id| - Notify.reassigned_merge_request_email(recipient_id, merge_request.id, merge_request.assignee_id_was).deliver + Notify.delay.reassigned_merge_request_email(recipient_id, merge_request.id, merge_request.assignee_id_was) end end end diff --git a/app/observers/note_observer.rb b/app/observers/note_observer.rb index fe01efcaac2..3f6d1dfcb70 100644 --- a/app/observers/note_observer.rb +++ b/app/observers/note_observer.rb @@ -11,7 +11,7 @@ class NoteObserver < ActiveRecord::Observer notify_team(note) elsif note.notify_author # Notify only author of resource - Notify.note_commit_email(note.commit_author.id, note.id).deliver + Notify.delay.note_commit_email(note.commit_author.id, note.id) else # Otherwise ignore it nil @@ -26,7 +26,7 @@ class NoteObserver < ActiveRecord::Observer if Notify.respond_to? notify_method team_without_note_author(note).map do |u| - Notify.send(notify_method, u.id, note.id).deliver + Notify.delay.send(notify_method, u.id, note.id) end end end diff --git a/app/observers/user_observer.rb b/app/observers/user_observer.rb index 73a1d00ca3b..c1179ed7881 100644 --- a/app/observers/user_observer.rb +++ b/app/observers/user_observer.rb @@ -2,7 +2,7 @@ class UserObserver < ActiveRecord::Observer def after_create(user) log_info("User \"#{user.name}\" (#{user.email}) was created") - Notify.new_user_email(user.id, user.password).deliver + Notify.delay.new_user_email(user.id, user.password) end def after_destroy user diff --git a/app/observers/users_project_observer.rb b/app/observers/users_project_observer.rb index 0c9c2b2614a..b969d6a13ef 100644 --- a/app/observers/users_project_observer.rb +++ b/app/observers/users_project_observer.rb @@ -1,7 +1,7 @@ class UsersProjectObserver < ActiveRecord::Observer def after_commit(users_project) return if users_project.destroyed? - Notify.project_access_granted_email(users_project.id).deliver + Notify.delay.project_access_granted_email(users_project.id) end def after_create(users_project) diff --git a/config/routes.rb b/config/routes.rb index 4c1f61e9a83..ffcfd1ee6f5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,7 +12,7 @@ Gitlab::Application.routes.draw do constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } constraints constraint do - mount Sidekiq::Web, at: "/admin/workers", as: :sidekiq + mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq end # Enable Grack support diff --git a/lib/tasks/resque.rake b/lib/tasks/resque.rake deleted file mode 100644 index e469aef3f94..00000000000 --- a/lib/tasks/resque.rake +++ /dev/null @@ -1,23 +0,0 @@ -require 'resque/tasks' - -namespace :resque do - task setup: :environment do - #Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } - end - - desc "Resque | kill all workers (using -QUIT), god will take care of them" - task :stop_workers => :environment do - #pids = Array.new - - #Resque.workers.each do |worker| - #pids << worker.to_s.split(/:/).second - #end - - #if pids.size > 0 - #system("kill -QUIT #{pids.join(' ')}") - #end - end -end - -desc "Alias for resque:work (To run workers on Heroku)" -task "jobs:work" => "resque:work" diff --git a/lib/tasks/sidekiq.rake b/lib/tasks/sidekiq.rake new file mode 100644 index 00000000000..6bbcb3da4bc --- /dev/null +++ b/lib/tasks/sidekiq.rake @@ -0,0 +1,23 @@ +namespace :sidekiq do + desc "GITLAB | Stop sidekiq" + task :stop do + run "bundle exec sidekiqctl stop #{pidfile}" + end + + desc "GITLAB | Start sidekiq" + task :start do + 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 &" + end + + def root_path + @root_path ||= File.join(File.expand_path(File.dirname(__FILE__)), "../..") + end + + def pidfile + "#{root_path}/tmp/pids/sidekiq.pid" + end + + def rails_env + ENV['RAILS_ENV'] || "production" + end +end diff --git a/resque.sh b/resque.sh deleted file mode 100755 index 145440fa814..00000000000 --- a/resque.sh +++ /dev/null @@ -1,2 +0,0 @@ -mkdir -p tmp/pids -nohup bundle exec rake environment resque:work QUEUE=post_receive,mailer,system_hook RAILS_ENV=production PIDFILE=tmp/pids/resque_worker.pid > ./log/resque.stdout.log 2>./log/resque.stderr.log &
\ No newline at end of file diff --git a/resque_dev.sh b/resque_dev.sh deleted file mode 100755 index b250caa9aee..00000000000 --- a/resque_dev.sh +++ /dev/null @@ -1,2 +0,0 @@ -mkdir -p tmp/pids -nohup bundle exec rake environment resque:work QUEUE=post_receive,mailer,system_hook VVERBOSE=1 RAILS_ENV=development PIDFILE=tmp/pids/resque_worker.pid > ./log/resque.log & |