- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我最近在我的 Rails 应用程序中安装了 Sidekiq gem 以在后台进程中发送电子邮件。然而,我还没有收到一封要发送的电子邮件,到目前为止,Stack Overflow 搜索让我两手空空。我不太了解 Sidekiq 或 Redis,所以部分问题可能是我真的不知道要搜索什么或如何解释错误消息。在安装 Sidekiq 之前,电子邮件可以使用 .deliver 方法正常发送。
当它尝试再次发送时,我收到一条错误消息“Connection reset by peer”,然后是“已到达文件末尾”。还有一条包含“sysread_nonblock”并提及 openssl 目录的警告消息。
2015-09-13T01:59:23.751Z 1400 TID-owidkv8b8 WARN: Errno::ECONNRESET: Connection reset by peer
2015-09-13T01:59:23.751Z 1400 TID-owidkv8b8 WARN: .../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/openssl/buffering.rb:182:in `sysread_nonblock'
这是我的代码。它基于 Rails 4.2.3 和 Ruby 2.2.1。
gem 文件
gem 'redis'
gem 'sidekiq'
Application.rb
config.active_job.queue_adapter = :sidekiq
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.office365.com',
port: 587,
authentication: :login,
user_name: ENV['office_email'],
password: ENV['office_pw'],
domain: 'example.com',
enable_starttls_auto: true
}
问题 Controller
QuestionMailer.question_email.deliver_later!
问题邮件
default from: "info@example.com"
def question_email
mail(to: "example@gmail.com", subject: 'Question Email')
end
当我启动我的本地服务器时,我会执行以下操作:
启动 Redis 服务器
redis-server /usr/local/etc/redis.conf
启动 Sidekiq
bundle exec sidekiq -q default -q mailers
启动 Rails Server(带工头)
foreman run rails server
这是我的完整日志:
2015-09-13T01:59:17.861Z 1400 TID-owidkv8b8 ActionMailer::DeliveryJob JID-2fb2df2aac71bb896b05c7f1 INFO: start
2015-09-13T01:59:23.750Z 1400 TID-owidkv8b8 ActionMailer::DeliveryJob JID-2fb2df2aac71bb896b05c7f1 INFO: fail: 5.889 sec
2015-09-13T01:59:23.751Z 1400 TID-owidkv8b8 WARN: {"class"=>"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper", "wrapped"=>"ActionMailer::DeliveryJob", "queue"=>"mailers", "args"=>[{"job_class"=>"ActionMailer::DeliveryJob", "job_id"=>"708d1ee4-7d66-493e-8b9f-0fefa7838262", "queue_name"=>"mailers", "arguments"=>["QuestionMailer", "question_email", "deliver_now!"]}], "retry"=>true, "jid"=>"2fb2df2aac71bb896b05c7f1", "created_at"=>1442109557.85662, "enqueued_at"=>1442109557.8567731, "error_message"=>"Connection reset by peer", "error_class"=>"Errno::ECONNRESET", "failed_at"=>1442109563.749469, "retry_count"=>0}
2015-09-13T01:59:23.751Z 1400 TID-owidkv8b8 WARN: Errno::ECONNRESET: Connection reset by peer
2015-09-13T01:59:23.751Z 1400 TID-owidkv8b8 WARN: .../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/openssl/buffering.rb:182:in `sysread_nonblock'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/openssl/buffering.rb:182:in `read_nonblock'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/protocol.rb:153:in `rbuf_fill'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/protocol.rb:134:in `readuntil'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/protocol.rb:144:in `readline'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:945:in `recv_response'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:931:in `block in getok'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:955:in `critical'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:929:in `getok'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:923:in `quit'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:616:in `do_finish'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:523:in `ensure in start'
.../.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/smtp.rb:523:in `start'
.../.rvm/gems/ruby-2.2.1/gems/mail-2.6.3/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
.../.rvm/gems/ruby-2.2.1/gems/mail-2.6.3/lib/mail/message.rb:252:in `deliver!'
.../.rvm/gems/ruby-2.2.1/gems/actionmailer-4.2.3/lib/action_mailer/message_delivery.rb:77:in `deliver_now!'
.../.rvm/gems/ruby-2.2.1/gems/actionmailer-4.2.3/lib/action_mailer/delivery_job.rb:10:in `perform'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/execution.rb:32:in `block in perform_now'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:115:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:115:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:553:in `block (2 levels) in compile'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:503:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:503:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:496:in `block (2 levels) in around'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:341:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:341:in `block (2 levels) in simple'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/logging.rb:23:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/logging.rb:23:in `block (4 levels) in <module:Logging>'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `block in instrument'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/notifications.rb:164:in `instrument'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/logging.rb:22:in `block (3 levels) in <module:Logging>'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/logging.rb:43:in `block in tag_logger'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `block in tagged'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:26:in `tagged'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `tagged'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/logging.rb:43:in `tag_logger'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/logging.rb:19:in `block (2 levels) in <module:Logging>'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:439:in `instance_exec'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:439:in `block in make_lambda'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:340:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:340:in `block in simple'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:495:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:495:in `block in around'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:503:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:503:in `call'
.../.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:88:in `run_callbacks'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/execution.rb:31:in `perform_now'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/execution.rb:21:in `execute'
.../.rvm/gems/ruby-2.2.1/gems/activejob-4.2.3/lib/active_job/queue_adapters/sidekiq_adapter.rb:42:in `perform'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/processor.rb:75:in `execute_job'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/chain.rb:127:in `block in invoke'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/logging.rb:30:in `with_context'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/server/logging.rb:7:in `call'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/chain.rb:132:in `call'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/middleware/chain.rb:132:in `invoke'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/processor.rb:51:in `block in process'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/processor.rb:98:in `stats'
.../.rvm/gems/ruby-2.2.1/gems/sidekiq-3.5.0/lib/sidekiq/processor.rb:50:in `process'
.../.rvm/gems/ruby-2.2.1/gems/celluloid-0.17.1.2/lib/celluloid/calls.rb:28:in `public_send'
.../.rvm/gems/ruby-2.2.1/gems/celluloid-0.17.1.2/lib/celluloid/calls.rb:28:in `dispatch'
.../.rvm/gems/ruby-2.2.1/gems/celluloid-0.17.1.2/lib/celluloid/call/async.rb:7:in `dispatch'
.../.rvm/gems/ruby-2.2.1/gems/celluloid-0.17.1.2/lib/celluloid/cell.rb:50:in `block in dispatch'
.../.rvm/gems/ruby-2.2.1/gems/celluloid-0.17.1.2/lib/celluloid/cell.rb:76:in `block in task'
.../.rvm/gems/ruby-2.2.1/gems/celluloid-0.17.1.2/lib/celluloid/actor.rb:339:in `block in task'
.../.rvm/gems/ruby-2.2.1/gems/celluloid-0.17.1.2/lib/celluloid/task.rb:44:in `block in initialize'
.../.rvm/gems/ruby-2.2.1/gems/celluloid-0.17.1.2/lib/celluloid/task/fibered.rb:14:in `block in create'
非常感谢您提供的任何见解!
最佳答案
对于遇到类似问题的任何人,我通过简单地将此行添加到 config/environments/development.rb 来修复错误
config.action_mailer.perform_deliveries = true
这默认设置为 false,因为通常您不想在开发模式下实际发送电子邮件。我不确定为什么 deliver_now 即使设置为 false 也能正常工作,但你能做什么......
关于ruby-on-rails - 使用 Sidekiq 时由对等方重置连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32545857/
我想使用 rails 控制台重新启动所有失败的作业。有没有办法做到这一点?我可以使用以下方法获取工作列表: require 'sidekiq/api' Sidekiq::Queue.new("mail
我想使用 Datadog 来监控一些后台作业的队列长度。 基本上我需要知道 Sidekiq 中代表队列的键的名称 ,以便我可以按照此处所述对其进行监控: https://docs.datadoghq.
我将 Sidekiq 与 Rails 一起使用,返回的并发值似乎是错误的。 Sidekiq.options[:concurrency] 返回 10 而不是 3,这是我的 config/sidekiq.
从Rails API中,我发现ActiveJob可以retry_job间隔: my_job_instance.enqueue my_job_instance.enqueue wait: 5.minut
我正在一个作业中进行一些处理,最终执行一个外部 shell 命令。该命令正在执行需要数小时才能完成的脚本。 问题是在我使用 spawn 启动脚本后和 detach如果我使用 kill -15 信号关闭
我有一个使用 Capistrano 部署的 Rails 3 应用程序。我最近添加了 Sidekiq。它在我的开发中运行良好。我同时主持 staging和 preview在同一台服务器上,它的预览无法正
我有一个简单的工作线程正在访问其自己的队列的大小: 需要“sidekiq/api” class TestWorker include Sidekiq::Worker def perform(*
我在我的 Rails 应用程序中使用 sidekiq。默认情况下,任何人都可以通过在 url 后附加“/sidekiq”来访问 Sidekiq。我只想用密码保护/验证 sidekiq 部分。我该怎么做
我正在在线阅读一些教程,这些教程告诉我们将 ActiveJob 与 Sidekiq 结合使用。但我不知道我们为什么要这样做。我看到 Sidekiq 具有 ActiveJob 的所有功能。 此外,在 S
我猴子修补了我的用户类(由设计支持)以像这样使用 ActiveJob: class User ActionMailer::DeliveryJob, :args=>["Devise::Mailer",
我有 sidekiq 作业对多种类型的资源进行处理。但是,对于特定类型的资源,例如:资源 X,我需要确保在任何给定时间只有一个 sidekiq 作业可以处理该特定资源。 例如,如果我有 3 个 sid
在过去的一年里,我对我的一项工作的流程进行了大量更改。诸如从相应模型上的 after_commit 而不是 after_create 触发它,以及清理逻辑和覆盖极端情况 我在我的 Heroku Rub
我看到this在 Sidekiq 官方 wiki 中,ActiveJob 会慢得多。 但它是在 2018 年 3 月根据此 issue 基于 Rails 4.2 和 Sidekiq 5.1.1 提到的
我使用 Rails 4 默认测试框架并编写了一些测试,这些测试也希望 Sidekiq 在“后台”做一些工作。但是当我运行 rake test 时,我的测试结果看起来像这样: .............
我们几周前在我们的系统中添加了监控用户事件,如下所示: class ApplicationController < ActionController::Base before_filter :lo
我正在运行 7 个 sidekiq 进程(货币设置为 40)和一个乘客网络服务器,连接到 postgres 数据库。 Rails 池设置设置为 100,postgres max_connectio
我第一次在 Rails 应用程序中使用 Sidekiq。这也是我第一次使用Redis。 我见过几个示例(Here、here、here),其中 initializers/sidekiq.rb 包含以下几
我刚开始使用 sidekiq 和 redis,我试图让 sidekiq 在 Heroku 上运行,但每次我部署 Rails 4 应用程序时它似乎都会崩溃。我在 Papertrail 中收到此错误: M
我有一个要求,我应该能够每秒运行 100 个 sidekiq 作业。 我将服务器容量增加到 8 个 CPU 并创建了 4 个 sidekiq 进程,但它仍然每分钟服务 50 个作业。 我不确定我在哪里
我在 Sidekiq 中有两种队列:“default/low”——满足网络请求和“background_queue”——运行后台进程,比如获取推文。我想在不同的 dyno 上运行“background
我是一名优秀的程序员,十分优秀!