gpt4 book ai didi

ruby-on-rails - Sidekiq 看不到我的 UserMailer

转载 作者:可可西里 更新时间:2023-11-01 11:00:49 29 4
gpt4 key购买 nike

class User < ActiveRecord::Base
def send_async_email
UserMailer.registration(self).deliver
end

def send_sync_email
UserMailer.delay.registration(self)
end
end

rails 控制台:

u = User.last
u.send_sync_email #=> Rendered user_mailer/registration.text.erb (0.4ms)
u.send_async_email #=> "5da2ec14f77b8191bebb2be6"

sidekiq 输出:

2014-04-25T19:08:41Z 40831 TID-owap5t5sw WARN: {"retry"=>true, "queue"=>"default", "class"=>"Sidekiq::Extensions::DelayedMailer", "args"=>["---\n- !ruby/class 'UserMailer'\n- :registration\n- - !ruby/object:User\n    attributes:\n      id: 35\n      user_name: Smot2hu2222\n      email: starker@gmail.com\n      password_digest: $2a$10$Ke2BEuuVZVwNOzSP2slxcOU7RliPSzpIaU.DmkqrvGwcJnR0kkwie\n      created_at: 2014-04-25 18:45:29.982656000 Z\n      updated_at: 2014-04-25 18:45:30.065059000 Z\n      register_key: 9af86f5ef9131ae515c71b728149f9aed1455aaa\n state: unregistered\n"], "jid"=>"5da2ec14f77b8191bebb2be6", "enqueued_at"=>1398452587.3401864, "error_message"=>"undefined class/module UserMailer", "error_class"=>"ArgumentError", "failed_at"=>1398452587.3426342, "retry_count"=>4, "retried_at"=>1398452921.5191402}
2014-04-25T19:08:41Z 40831 TID-owap5t5sw WARN: undefined class/module UserMailer
2014-04-25T19:08:41Z 40831 TID-owap5t5sw WARN: /home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:334:in `path2class'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:334:in `resolve_class'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:71:in `deserialize'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:104:in `visit_Psych_Nodes_Scalar'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:259:in `block in register_empty'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:259:in `each'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:259:in `register_empty'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:122:in `visit_Psych_Nodes_Sequence'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:240:in `visit_Psych_Nodes_Document'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:15:in `visit'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/visitor.rb:5:in `accept'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:20:in `accept'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych/nodes/node.rb:35:in `to_ruby'
/home/starkers/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:130:in `load'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/extensions/action_mailer.rb:16:in `perform'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/processor.rb:50:in `block (2 levels) in process'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:122:in `call'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:122:in `block in invoke'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/server/retry_jobs.rb:62:in `call'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/logging.rb:22:in `with_context'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:127:in `call'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/middleware/chain.rb:127:in `invoke'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/processor.rb:49:in `block in process'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/processor.rb:92:in `stats'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-3.0.0/lib/sidekiq/processor.rb:48:in `process'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/celluloid-0.15.2/lib/celluloid/calls.rb:122:in `dispatch'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
/home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'

我猜这是愚蠢的事情?我需要配置 sidekiq 来加载我的邮件程序,诸如此类?

最佳答案

我需要重启 sidekiq。脸红。通过按 crtl + c 然后使用 bundle exec sidekiq 再次启动它来执行此操作:

sidekiq:

    ^[^C2014-04-25T19:16:11Z 40831 TID-9048o INFO: Shutting down
2014-04-25T19:16:12Z 40831 TID-mf5qw INFO: Shutting down 25 quiet workers
starkers@ubuntu:~/Desktop/app$ bundle exec sidekiq

s
ss
sss sss ss
s sss s ssss sss ____ _ _ _ _
s sssss ssss / ___|(_) __| | ___| | _(_) __ _
s sss \___ \| |/ _` |/ _ \ |/ / |/ _` |
s sssss s ___) | | (_| | __/ <| | (_| |
ss s s |____/|_|\__,_|\___|_|\_\_|\__, |
s s s |_|
s s
sss
sss

2014-04-25T19:17:01Z 8392 TID-61jek INFO: Running in ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
2014-04-25T19:17:01Z 8392 TID-61jek INFO: See LICENSE and the LGPL-3.0 for licensing details.
2014-04-25T19:17:01Z 8392 TID-61jek INFO: Starting processing, hit Ctrl-C to stop
2014-04-25T19:17:01Z 8392 TID-rwouc INFO: Booting Sidekiq 3.0.0 with redis options {}

rails 控制台:

reload!
u = User.last
u.send_sync_email #=> Rendered user_mailer/registration.text.erb (0.4ms)
u.send_async_email #=> "7dbefe20b8df15ea13f78a89"

回到 sidekiq,您应该看到作业的 pid 与 send_async_email 方法返回的 pid 相同:

2014-04-25T19:18:42Z 8392 TID-owsho Sidekiq::Extensions::DelayedMailer JID-7dbefe20b8df15ea13f78a89 INFO: start
2014-04-25T19:18:46Z 8392 TID-owsho Sidekiq::Extensions::DelayedMailer JID-7dbefe20b8df15ea13f78a89 INFO: done: 3.758 sec

关于ruby-on-rails - Sidekiq 看不到我的 UserMailer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23301224/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com