Read about our upcoming Code of Conduct on this issue

Commit 71bd9568 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

email via sidekiq. start and stop rake tasks

parent e3805a6f80cd
...@@ -84,7 +84,6 @@ gem "draper", "~> 0.18.0" ...@@ -84,7 +84,6 @@ gem "draper", "~> 0.18.0"
gem 'slim' gem 'slim'
gem 'sinatra', :require => nil gem 'sinatra', :require => nil
gem 'sidekiq', '2.6.4' gem 'sidekiq', '2.6.4'
gem 'sidekiq_mailer'
# HTTP requests # HTTP requests
gem "httparty" gem "httparty"
......
...@@ -407,10 +407,6 @@ GEM ...@@ -407,10 +407,6 @@ GEM
multi_json (~> 1) multi_json (~> 1)
redis (~> 3) redis (~> 3)
redis-namespace redis-namespace
sidekiq_mailer (0.0.4)
actionmailer (~> 3.0)
activesupport (~> 3.0)
sidekiq (~> 2.3)
simplecov (0.7.1) simplecov (0.7.1)
multi_json (~> 1.0) multi_json (~> 1.0)
simplecov-html (~> 0.7.1) simplecov-html (~> 0.7.1)
...@@ -543,7 +539,6 @@ DEPENDENCIES ...@@ -543,7 +539,6 @@ DEPENDENCIES
settingslogic settingslogic
shoulda-matchers (= 1.3.0) shoulda-matchers (= 1.3.0)
sidekiq (= 2.6.4) sidekiq (= 2.6.4)
sidekiq_mailer
simplecov simplecov
sinatra sinatra
six six
......
web: bundle exec rails s -p $PORT web: bundle exec rails s -p $PORT
worker: bundle exec sidekiq -q post_receive,mailer,system_hook,common worker: bundle exec rake sidekiq:start
class Notify < ActionMailer::Base class Notify < ActionMailer::Base
include Sidekiq::Mailer
add_template_helper ApplicationHelper add_template_helper ApplicationHelper
add_template_helper GitlabMarkdownHelper add_template_helper GitlabMarkdownHelper
......
...@@ -251,7 +251,7 @@ def items_for entity ...@@ -251,7 +251,7 @@ def items_for entity
def send_move_instructions def send_move_instructions
self.users_projects.each do |member| self.users_projects.each do |member|
Notify.project_was_moved_email(member.id).deliver Notify.delay.project_was_moved_email(member.id)
end end
end end
......
...@@ -3,7 +3,7 @@ class IssueObserver < ActiveRecord::Observer ...@@ -3,7 +3,7 @@ class IssueObserver < ActiveRecord::Observer
def after_create(issue) def after_create(issue)
if issue.assignee && issue.assignee != current_user if issue.assignee && issue.assignee != current_user
Notify.new_issue_email(issue.id).deliver Notify.delay.new_issue_email(issue.id)
end end
end end
...@@ -16,7 +16,7 @@ def after_update(issue) ...@@ -16,7 +16,7 @@ def after_update(issue)
if status if status
Note.create_status_change_note(issue, current_user, status) Note.create_status_change_note(issue, current_user, status)
[issue.author, issue.assignee].compact.each do |recipient| [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 end
end end
...@@ -27,7 +27,7 @@ def send_reassigned_email(issue) ...@@ -27,7 +27,7 @@ def send_reassigned_email(issue)
recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id && id != current_user.id } recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id && id != current_user.id }
recipient_ids.each do |recipient_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 end
end end
...@@ -3,7 +3,7 @@ class MergeRequestObserver < ActiveRecord::Observer ...@@ -3,7 +3,7 @@ class MergeRequestObserver < ActiveRecord::Observer
def after_create(merge_request) def after_create(merge_request)
if merge_request.assignee && merge_request.assignee != current_user 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
end end
...@@ -25,7 +25,7 @@ def send_reassigned_email(merge_request) ...@@ -25,7 +25,7 @@ def send_reassigned_email(merge_request)
recipients_ids.delete current_user.id recipients_ids.delete current_user.id
recipients_ids.each do |recipient_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 end
end end
...@@ -11,7 +11,7 @@ def send_notify_mails(note) ...@@ -11,7 +11,7 @@ def send_notify_mails(note)
notify_team(note) notify_team(note)
elsif note.notify_author elsif note.notify_author
# Notify only author of resource # 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 else
# Otherwise ignore it # Otherwise ignore it
nil nil
...@@ -26,7 +26,7 @@ def notify_team(note) ...@@ -26,7 +26,7 @@ def notify_team(note)
if Notify.respond_to? notify_method if Notify.respond_to? notify_method
team_without_note_author(note).map do |u| 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 end
end end
......
...@@ -2,7 +2,7 @@ class UserObserver < ActiveRecord::Observer ...@@ -2,7 +2,7 @@ class UserObserver < ActiveRecord::Observer
def after_create(user) def after_create(user)
log_info("User \"#{user.name}\" (#{user.email}) was created") 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 end
def after_destroy user def after_destroy user
......
class UsersProjectObserver < ActiveRecord::Observer class UsersProjectObserver < ActiveRecord::Observer
def after_commit(users_project) def after_commit(users_project)
return if users_project.destroyed? return if users_project.destroyed?
Notify.project_access_granted_email(users_project.id).deliver Notify.delay.project_access_granted_email(users_project.id)
end end
def after_create(users_project) def after_create(users_project)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
constraints constraint do constraints constraint do
mount Sidekiq::Web, at: "/admin/workers", as: :sidekiq mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq
end end
# Enable Grack support # Enable Grack support
......
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"
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
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
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 &
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment