[edit]我可以使用带有守护进程的共享服务器上的delayed_job插件来延迟所有邮件...除了使用authlogic的邮件。 我不知道在哪里搜索,以及为什么它以其他方式工作。
守护进程(关闭)delayed_job& delayed_mail_mailer(on)authlogic(reset_password):发送 守护进程(on)delayed_job& delayed_mail_mailer(on)other_model(send_mail):send 守护进程(on)delayed_job& delayed_mail_mailer(on)authlogic(reset_password):没有!
在哪里搜索问题??
app / initializer / delayed_mailer.rb:
class ActionMailer::Base
include Delayed::Mailer
end
config / initializers / delayed_job_config.rb:
Delayed::Job.destroy_failed_jobs = false
silence_warnings do
Delayed::Job.const_set("MAX_ATTEMPTS", 3)
Delayed::Job.const_set("MAX_RUN_TIME", 5.minutes)
end
script / dalayed_job:
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
daemon_options = {
:multiple => false,
:dir_mode => :normal,
:dir => File.join(dir, 'tmp', 'pids'),
:backtrace => true,
:log_output => true
}
Daemons.run_proc('delayed_job', daemon_options) do
Dir.chdir dir
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
require File.join('config', 'environment')
Delayed::Worker.new.start
end
模型/控制器/ passwoed_reset_controller.rb
def create
@user = User.find_by_email(params[:email])
if @user
Notifier::deliver_password_reset_instructions(@user)
flash[:notice] = t('ResetInstructionSend') + t('CheckMail')
redirect_to root_url
else
flash[:notice] = t('NoUserMail')
render :action => :new
end
end
控制器/ other_controller.rb
def update
@patent = Patent.find(params[:id])
# update all
@patent.update_attributes(params[:patent])
@user = @patent.user
@skill = @patent.skill
@current_user = current_user
Notifier::deliver_specialist_confirmation(@user, @skill, @current_user)
end
模型/ notifier.rb
def password_reset_instructions(user)
recipients user.email
from "Skill Forest"
subject "Password Reset Instructions"
body :edit_password_reset_url => edit_password_reset_url(user.perishable_token),:user => user
端
def specialist_confirmation (user, skill, current_user)
recipients user.email
from "Skill Forest"
subject "Bravo"
body :user => user, :skill => skill, :current_user => current_user
end
更多信息:Rails 2.3.5& tobi delayed_job&守护进程1.0.10 我在dreamhost共享虚拟主机上,但在我的计算机上的开发模式上看起来一样。
[编辑2]我会控制以确定,但似乎只有最长的运行时间太短......
[编辑3]我尝试的另一种方式:control if pid exist
答案 0 :(得分:0)
只是为了翻页...传递Rails 3并更新gem ......一切都很好。而且更简单。
二进制编码之谜!