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

email via sidekiq. start and stop rake tasks

parent c7bb3a1f
......@@ -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"
......
......@@ -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
......
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
include Sidekiq::Mailer
add_template_helper ApplicationHelper
add_template_helper GitlabMarkdownHelper
......
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
......
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)
......
......@@ -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
......
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