Collectiveidea'nın delayed_job özelliğini kullanarak bir Rails 3 uygulamasında posta göndermeye çalışıyorum. Düzenli olarak posta göndermeye çalışırsam (.deliver) iyi çalışır, ancak gecikmeli işe geçtiğimde işler parçalanır.Raylar: Kesinlikle delayed_job ile güdük. Her yerde argüman almayan
Ben delayed_job MySQL tablosunda olsun standart hatadır:
{tanımsız yöntem `adı' nil için: NilClass ...
'adı' İlk argüman olduğunu posta mahallinin görünümünde (contact.name). Eğer gecikme çıkarsam tekrar işe yarar.
Ben görünümünde @contact tüm başvuruları kaldırırsanız, ben Kısacası bir mesaj
göndermek için gerekli
{A gönderen (Return-Path, göndereni veya Dan ) olsun hiç bir argümanı anlamadığı görülüyor.
aşağıda tüm ilgili kod - Herkes bunun için herhangi bir öneriniz varsa çok mutluluk duyacağız
KONTROL
def sendmail @contact = Contact.new(params[:contact]) if @contact.save ContactMailer.delay.contact_mail(@contact) flash[:notice] = 'Your message has been successfully sent' redirect_to root_path else render :action => 'index' end end
MAILER:
class ContactMailer < ActionMailer::Base default :from => "[email protected]" def contact_mail(contact) @contact = contact mail(:to => '[email protected]', :subject => 'Contact Form Query', :from => '[email protected]', :content_type => 'text/plain') end handle_asynchronously :contact_mail, :run_at => Proc.new { 2.seconds.from_now } end
MAILER GÖRÜNÜM:
You have received a new query: ----------------------------------- <%= @contact.name %> <%= @contact.business %> <%= @contact.phone %> ----------------------- <%= @contact.message %> -----------------------
başlatıcı:
Delayed::Worker.destroy_failed_jobs = false Delayed::Worker.max_run_time = 5.weeks
Ve nihayet, tam hata iletisi:
{undefined method `name' for nil:NilClass /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/whiny_nil.rb:48:in `method_missing' /Users/john/Websites/Rails/InDevelopment/connectted/app/views/contact_mailer/contact_mail.html.erb:4:in `_app_views_contact_mailer_contact_mail_html_erb___3386534441642202773_2166008980__4301703149293725172' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/template.rb:135:in `block in render' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications.rb:54:in `instrument' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/template.rb:127:in `render' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/render/rendering.rb:59:in `block in _render_template' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications.rb:52:in `block in instrument' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications.rb:52:in `instrument' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/render/rendering.rb:56:in `_render_template' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/render/rendering.rb:26:in `render' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:114:in `_render_template' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:108:in `render_to_body' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:101:in `render_to_string' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:92:in `render' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/deprecated_api.rb:111:in `render' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:210:in `block in create_parts' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:208:in `each' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:208:in `create_parts' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/deprecated_api.rb:143:in `create_parts' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:77:in `process' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:446:in `process' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:441:in `initialize' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `new' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `method_missing' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/performable_mailer.rb:6:in `perform' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/backend/base.rb:83:in `invoke_job' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:119:in `block (2 levels) in run' /Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:57:in `timeout' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed /worker.rb:119:in `block in run' /Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:118:in `run' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:176:in `reserve_and_run_one_job' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:103:in `block in work_off' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:102:in `times' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:102:in `work_off' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:77:in `block (2 levels) in start' /Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:76:in `block in start' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:73:in `loop' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:73:in `start' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:100:in `run' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:79:in `block in run_process' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `call' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `block in start_proc' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call_as_daemon' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:254:in `start_proc' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:294:in `start' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/controller.rb:70:in `run' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons.rb:193:in `block in run_proc' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `call' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `catch_exceptions' /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons.rb:192:in `run_proc' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:78:in `run_process' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:72:in `block in daemonize' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:70:in `times' /Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:70:in `daemonize' script/delayed_job:5:in `<main>' |
I varsayarak hiçbiri aşağıya sorun çözüldü? Bunu hiç anladın mı? Benim benzer bir sorunu yaşıyorum, benim durumumda işlerim “başarılı” ama aslında hiçbir şey gerçekleşmiyor. İlk satıra giriş ekledim ve hiçbir şeyim yok. Ben (a) rvm (benim uygulama 1.9.2, benim sistem ruby 1.8.7) veya b) mongoid bir şekilde (her ne kadar iyi iş bulmalarına rağmen) ile ilgili olduğunu sanıyorum. Ben bu noktada 1.9.2 altında çalışacak şekilde nasıl daemon almak için emin değilim rağmen, ben, rvm şey araştırmak için gidiyorum. – Brad
Merhaba Brad - ne yazık ki hiçbir cevap bulunamadı. Ben el ile sunucudan el ile cronning elle başvurma başvurdu düşünüyorum, bu gerçekten ideal bir çözüm değildir. – PlankTon
Bummer. Ben de anlamadım. Benim durumumda, iş konsolu rayları içinde oluşturup “Gecikmeli :: Worker.new.start” ı çağırırsam, işe yarayacaktır. Ancak, uygulamanın başka bir uçbirimdeki kök dizinde "script/delayed_job start" komutunu çalıştırırsam kesinlikle bir şey olmaz. İşleri bulur, kütük "1 iş bulundu, 0 başarısız" diyor ama hiçbir şey olmadı. İşçinin bu durumda başka bir süreçte başlamasından bu yana, nasıl hata ayıklanacağı konusunda hiçbir fikrim yok, ama bu süreç bir şekilde farklı bir ortamda çalışarak ilişkili olmalıdır. – Brad