Sidekiq/Redis/Rails - 发送在分支上工作,但现在不会在开发上交付
Sidekiq/Redis/Rails - Sending was working on the branch, but now will not deliver on development
Ruby版本:2.6.5
Rails版本:6.1.3.1
Sidekiq/专业版/企业版:6.2
初始化器:无初始化器
Sidekiq.yml:
:verbose: true
:concurrency: 25
:queues:
- [mailers, 7]
- [default, 5]
错误信息:NONE
完整的 Sidekiq 回溯:
****** (development) $ bundle exec sidekiq
m,
`$b
.ss, $$: .,d$
`$$P,d$P' .,md$P"'
,$$$$$b/md$$$P^'
.d$$$$$$/$$$P'
$$^' `"/$$$' ____ _ _ _ _
$: ,$$: / ___|(_) __| | ___| | _(_) __ _
`b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` |
$$: ___) | | (_| | __/ <| | (_| |
$$ |____/|_|\__,_|\___|_|\_\_|\__, |
.d$$ |_|
2021-06-13T15:22:14.594Z pid=756 tid=oxyx50z9s INFO: Booted Rails 6.1.3.1 application in development environment
2021-06-13T15:22:14.594Z pid=756 tid=oxyx50z9s INFO: Running in ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
2021-06-13T15:22:14.594Z pid=756 tid=oxyx50z9s INFO: See LICENSE and the LGPL-3.0 for licensing details.
2021-06-13T15:22:14.595Z pid=756 tid=oxyx50z9s INFO: Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org
2021-06-13T15:22:14.595Z pid=756 tid=oxyx50z9s INFO: Booting Sidekiq 6.2.1 with redis options {}
2021-06-13T15:22:14.597Z pid=756 tid=oxyx50z9s DEBUG: Client Middleware:
2021-06-13T15:22:14.597Z pid=756 tid=oxyx50z9s DEBUG: Server Middleware: Raven::Sidekiq::CleanupMiddleware
2021-06-13T15:22:14.598Z pid=756 tid=oxyx50z9s INFO: Starting processing, hit Ctrl-C to stop
2021-06-13T15:22:14.598Z pid=756 tid=oxyx50z9s DEBUG: {:queues=>["mailers", "mailers", "mailers", "mailers", "mailers", "mailers", "mailers", "default", "default", "default", "default", "default"], :labels=>[], :concurrency=>25, :require=>".", :strict=>false, :environment=>nil, :timeout=>25, :poll_interval_average=>nil, :average_scheduled_poll_interval=>5, :error_handlers=>[#<Sidekiq::ExceptionHandler::Logger:0x00007ffff8446a88>, #<Raven::Sidekiq::ErrorHandler:0x00007ffffa9bddc0>], :death_handlers=>[], :lifecycle_events=>{:startup=>[], :quiet=>[], :shutdown=>[], :heartbeat=>[]}, :dead_max_jobs=>10000, :dead_timeout_in_seconds=>15552000, :reloader=>#<Sidekiq::Rails::Reloader @app=Bdcommunity::Application>, :verbose=>true, :config_file=>"./config/sidekiq.yml", :tag=>"bdcommunity", :identity=>"DESKTOP***", :fetch=>#<Sidekiq::BasicFetch:0x00007ffffd789bc8 @options={...}, @strictly_ordered_queues=false, @queues=["queue:mailers", "queue:mailers", "queue:mailers", "queue:mailers", "queue:mailers", "queue:mailers", "queue:mailers", "queue:default", "queue:default", "queue:default", "queue:default", "queue:default"]>}
2021-06-13T15:23:41.567Z pid=756 tid=oxyy3dekc class=ActionMailer::MailDeliveryJob jid=1430f4cf1b9ea1c8f7578578 INFO: start
2021-06-13T15:23:41.584Z pid=756 tid=oxyy3dfsg class=ActionMailer::MailDeliveryJob jid=24dc64f44ab2088912a506e2 INFO: start
2021-06-13T15:23:41.584Z pid=756 tid=oxyy0umak class=ActionMailer::MailDeliveryJob jid=dce3868b2802b2a44c964f80 INFO: start
2021-06-13T15:23:41.584Z pid=756 tid=oxyy3dgjc class=ActionMailer::MailDeliveryJob jid=c85bd721343289b44218bd5d INFO: start
2021-06-13T15:23:41.585Z pid=756 tid=oxyy3df2o class=ActionMailer::MailDeliveryJob jid=81d4a665cc70e7056bfee2bc INFO: start
完整的 Redis 回溯:
630:M 13 Jun 2021 11:21:44.283 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
630:M 13 Jun 2021 11:21:44.283 # Server initialized
630:M 13 Jun 2021 11:21:44.283 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
630:M 13 Jun 2021 11:21:44.283 * Loading RDB produced by version 6.2.1
630:M 13 Jun 2021 11:21:44.283 * RDB age 152 seconds
630:M 13 Jun 2021 11:21:44.283 * RDB memory usage when created 1.42 Mb
630:M 13 Jun 2021 11:21:44.284 * DB loaded from disk: 0.000 seconds
630:M 13 Jun 2021 11:21:44.284 * Ready to accept connections
630:M 13 Jun 2021 11:26:45.030 * 100 changes in 300 seconds. Saving...
630:M 13 Jun 2021 11:26:45.037 * Background saving started by pid 1004
1004:C 13 Jun 2021 11:26:45.050 * DB saved on disk
630:M 13 Jun 2021 11:26:45.138 * Background saving terminated with success
630:M 13 Jun 2021 11:31:46.019 * 100 changes in 300 seconds. Saving...
630:M 13 Jun 2021 11:31:46.026 * Background saving started by pid 1216
1216:C 13 Jun 2021 11:31:46.047 * DB saved on disk
630:M 13 Jun 2021 11:31:46.127 * Background saving terminated with success
完全相关Rails 服务器回溯:
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: 7d4823ed-e0f8-40ec-9a25-ddac8e373de5) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd89c8008 @uri=#<URI::GID gid://***>>, #<GlobalID:0x00007fffd89ff918 @uri=#<URI::GID gid://***>>, "Test Number 3"]}
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: ac28e08d-3318-41e5-83c8-83010be6a1d3) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd8bbbb80 @uri=#<URI::GID gid://***>>, #<GlobalID:0x00007fffd8c006b8 @uri=#<URI::GID gid://***>>, "Test Number 3"]}
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: 87e09cd3-631e-46c3-9f2e-0e7f622d2d7a) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd8ef99f0 @uri=#<URI::GID gid://***>>, #<GlobalID:0x00007fffd8f35770 @uri=#<URI::GID gid://***>>, "Test Number 3"]}
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: 3eebfc8c-faba-40d0-9edf-64e34cd1161b) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd91572d8 @uri=#<URI::GID gid://***>>, #<GlobalID:0x00007fffd91796f8 @uri=#<URI::GID gid://***>>, "Test Number 3"]}
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: 26cca661-437f-4d3e-a341-02fbe53ebb6a) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd934e2d0 @uri=#<URI::GID gid://***/***/**>>, #<GlobalID:0x00007fffd9352628 @uri=#<URI::GID gid://****>>, "Test Number 3"]}
Completed 302 Found in 439ms (ActiveRecord: 25.8ms | Allocations: 80420)
有谁知道为什么现在无法发送电子邮件?
答案原来是生产需要大量设置才能让 sidekiq 工作。
第一个主要变化是添加了一个 sidekiq.rb 初始值设定项:
Sidekiq.default_worker_options = {
backtrace: true,
retry: true
}
sidekiq_redis = lambda do
Redis.new(url: ENV['REDIS_URL'], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE })
end
Sidekiq.configure_client do |config|
config.redis = ConnectionPool.new(size: 2, &sidekiq_redis)
end
Sidekiq.configure_server do |config|
config.redis = ConnectionPool.new(size: 17, &sidekiq_redis)
end
Sidekiq::Extensions.enable_delay!
请注意,其中一些(OpenSSL 部分)来自我们必须解决的新问题,当我们从免费的 heroku redis 计划升级到最低付费层时。提示:如果您升级到第一个付费层而不进行大量调整,您的应用程序将会崩溃。所以在你离开免费的 heroku redis 计划之前做大量的研究。
我们还必须添加一个新的 WORKER。我们最初只有一台普通的测功机。我们必须实际添加一个工人,像这样:
请注意,还有一个 sidekiq.yml。你也需要它:
:verbose: true
:concurrency: 15
:queues:
- [mailers, 7]
- [default, 5]
- List item
此外,如果您使用 actioncable,您可能还需要更新 actioncable.yml 文件:
development:
adapter: redis
url: redis://localhost:6379/1
test:
adapter: async
production:
adapter: redis
url: <%= ENV['REDIS_URL'] %>
ssl_params:
verify_mode: <%= OpenSSL::SSL::VERIFY_NONE %>
同样,最后一部分 ssl_params 是修复升级到 redis 付费层时引起的问题。
注意:虽然我们的电子邮件现在可以发送,但我们还没有完全解决 SSL 问题。我们在 Heroku 中有一张支持票。但我希望至少这将帮助您更好地了解您可能需要更改哪些内容才能让 sidekiq 最初工作。
最后一点:我们了解到 RedisToGo 仅适用于 Redis 4 或其他版本。所以如果你想使用sidekiq,你不能使用RedisToGo,因为它显然不适用于Redis 4。你需要使用Heroku Redis。这是我们所做的另一项更改,它允许 sidekiq 投入生产。
Ruby版本:2.6.5 Rails版本:6.1.3.1 Sidekiq/专业版/企业版:6.2
初始化器:无初始化器
Sidekiq.yml:
:verbose: true
:concurrency: 25
:queues:
- [mailers, 7]
- [default, 5]
错误信息:NONE
完整的 Sidekiq 回溯:
****** (development) $ bundle exec sidekiq
m,
`$b
.ss, $$: .,d$
`$$P,d$P' .,md$P"'
,$$$$$b/md$$$P^'
.d$$$$$$/$$$P'
$$^' `"/$$$' ____ _ _ _ _
$: ,$$: / ___|(_) __| | ___| | _(_) __ _
`b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` |
$$: ___) | | (_| | __/ <| | (_| |
$$ |____/|_|\__,_|\___|_|\_\_|\__, |
.d$$ |_|
2021-06-13T15:22:14.594Z pid=756 tid=oxyx50z9s INFO: Booted Rails 6.1.3.1 application in development environment
2021-06-13T15:22:14.594Z pid=756 tid=oxyx50z9s INFO: Running in ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
2021-06-13T15:22:14.594Z pid=756 tid=oxyx50z9s INFO: See LICENSE and the LGPL-3.0 for licensing details.
2021-06-13T15:22:14.595Z pid=756 tid=oxyx50z9s INFO: Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org
2021-06-13T15:22:14.595Z pid=756 tid=oxyx50z9s INFO: Booting Sidekiq 6.2.1 with redis options {}
2021-06-13T15:22:14.597Z pid=756 tid=oxyx50z9s DEBUG: Client Middleware:
2021-06-13T15:22:14.597Z pid=756 tid=oxyx50z9s DEBUG: Server Middleware: Raven::Sidekiq::CleanupMiddleware
2021-06-13T15:22:14.598Z pid=756 tid=oxyx50z9s INFO: Starting processing, hit Ctrl-C to stop
2021-06-13T15:22:14.598Z pid=756 tid=oxyx50z9s DEBUG: {:queues=>["mailers", "mailers", "mailers", "mailers", "mailers", "mailers", "mailers", "default", "default", "default", "default", "default"], :labels=>[], :concurrency=>25, :require=>".", :strict=>false, :environment=>nil, :timeout=>25, :poll_interval_average=>nil, :average_scheduled_poll_interval=>5, :error_handlers=>[#<Sidekiq::ExceptionHandler::Logger:0x00007ffff8446a88>, #<Raven::Sidekiq::ErrorHandler:0x00007ffffa9bddc0>], :death_handlers=>[], :lifecycle_events=>{:startup=>[], :quiet=>[], :shutdown=>[], :heartbeat=>[]}, :dead_max_jobs=>10000, :dead_timeout_in_seconds=>15552000, :reloader=>#<Sidekiq::Rails::Reloader @app=Bdcommunity::Application>, :verbose=>true, :config_file=>"./config/sidekiq.yml", :tag=>"bdcommunity", :identity=>"DESKTOP***", :fetch=>#<Sidekiq::BasicFetch:0x00007ffffd789bc8 @options={...}, @strictly_ordered_queues=false, @queues=["queue:mailers", "queue:mailers", "queue:mailers", "queue:mailers", "queue:mailers", "queue:mailers", "queue:mailers", "queue:default", "queue:default", "queue:default", "queue:default", "queue:default"]>}
2021-06-13T15:23:41.567Z pid=756 tid=oxyy3dekc class=ActionMailer::MailDeliveryJob jid=1430f4cf1b9ea1c8f7578578 INFO: start
2021-06-13T15:23:41.584Z pid=756 tid=oxyy3dfsg class=ActionMailer::MailDeliveryJob jid=24dc64f44ab2088912a506e2 INFO: start
2021-06-13T15:23:41.584Z pid=756 tid=oxyy0umak class=ActionMailer::MailDeliveryJob jid=dce3868b2802b2a44c964f80 INFO: start
2021-06-13T15:23:41.584Z pid=756 tid=oxyy3dgjc class=ActionMailer::MailDeliveryJob jid=c85bd721343289b44218bd5d INFO: start
2021-06-13T15:23:41.585Z pid=756 tid=oxyy3df2o class=ActionMailer::MailDeliveryJob jid=81d4a665cc70e7056bfee2bc INFO: start
完整的 Redis 回溯:
630:M 13 Jun 2021 11:21:44.283 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
630:M 13 Jun 2021 11:21:44.283 # Server initialized
630:M 13 Jun 2021 11:21:44.283 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
630:M 13 Jun 2021 11:21:44.283 * Loading RDB produced by version 6.2.1
630:M 13 Jun 2021 11:21:44.283 * RDB age 152 seconds
630:M 13 Jun 2021 11:21:44.283 * RDB memory usage when created 1.42 Mb
630:M 13 Jun 2021 11:21:44.284 * DB loaded from disk: 0.000 seconds
630:M 13 Jun 2021 11:21:44.284 * Ready to accept connections
630:M 13 Jun 2021 11:26:45.030 * 100 changes in 300 seconds. Saving...
630:M 13 Jun 2021 11:26:45.037 * Background saving started by pid 1004
1004:C 13 Jun 2021 11:26:45.050 * DB saved on disk
630:M 13 Jun 2021 11:26:45.138 * Background saving terminated with success
630:M 13 Jun 2021 11:31:46.019 * 100 changes in 300 seconds. Saving...
630:M 13 Jun 2021 11:31:46.026 * Background saving started by pid 1216
1216:C 13 Jun 2021 11:31:46.047 * DB saved on disk
630:M 13 Jun 2021 11:31:46.127 * Background saving terminated with success
完全相关Rails 服务器回溯:
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: 7d4823ed-e0f8-40ec-9a25-ddac8e373de5) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd89c8008 @uri=#<URI::GID gid://***>>, #<GlobalID:0x00007fffd89ff918 @uri=#<URI::GID gid://***>>, "Test Number 3"]}
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: ac28e08d-3318-41e5-83c8-83010be6a1d3) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd8bbbb80 @uri=#<URI::GID gid://***>>, #<GlobalID:0x00007fffd8c006b8 @uri=#<URI::GID gid://***>>, "Test Number 3"]}
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: 87e09cd3-631e-46c3-9f2e-0e7f622d2d7a) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd8ef99f0 @uri=#<URI::GID gid://***>>, #<GlobalID:0x00007fffd8f35770 @uri=#<URI::GID gid://***>>, "Test Number 3"]}
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: 3eebfc8c-faba-40d0-9edf-64e34cd1161b) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd91572d8 @uri=#<URI::GID gid://***>>, #<GlobalID:0x00007fffd91796f8 @uri=#<URI::GID gid://***>>, "Test Number 3"]}
[ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: 26cca661-437f-4d3e-a341-02fbe53ebb6a) to Sidekiq(mailers) with arguments: "NotificationMailer", "private_message_received", "deliver_now", {:args=>[#<GlobalID:0x00007fffd934e2d0 @uri=#<URI::GID gid://***/***/**>>, #<GlobalID:0x00007fffd9352628 @uri=#<URI::GID gid://****>>, "Test Number 3"]}
Completed 302 Found in 439ms (ActiveRecord: 25.8ms | Allocations: 80420)
有谁知道为什么现在无法发送电子邮件?
答案原来是生产需要大量设置才能让 sidekiq 工作。
第一个主要变化是添加了一个 sidekiq.rb 初始值设定项:
Sidekiq.default_worker_options = {
backtrace: true,
retry: true
}
sidekiq_redis = lambda do
Redis.new(url: ENV['REDIS_URL'], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE })
end
Sidekiq.configure_client do |config|
config.redis = ConnectionPool.new(size: 2, &sidekiq_redis)
end
Sidekiq.configure_server do |config|
config.redis = ConnectionPool.new(size: 17, &sidekiq_redis)
end
Sidekiq::Extensions.enable_delay!
请注意,其中一些(OpenSSL 部分)来自我们必须解决的新问题,当我们从免费的 heroku redis 计划升级到最低付费层时。提示:如果您升级到第一个付费层而不进行大量调整,您的应用程序将会崩溃。所以在你离开免费的 heroku redis 计划之前做大量的研究。
我们还必须添加一个新的 WORKER。我们最初只有一台普通的测功机。我们必须实际添加一个工人,像这样:
请注意,还有一个 sidekiq.yml。你也需要它:
:verbose: true
:concurrency: 15
:queues:
- [mailers, 7]
- [default, 5]
- List item
此外,如果您使用 actioncable,您可能还需要更新 actioncable.yml 文件:
development:
adapter: redis
url: redis://localhost:6379/1
test:
adapter: async
production:
adapter: redis
url: <%= ENV['REDIS_URL'] %>
ssl_params:
verify_mode: <%= OpenSSL::SSL::VERIFY_NONE %>
同样,最后一部分 ssl_params 是修复升级到 redis 付费层时引起的问题。
注意:虽然我们的电子邮件现在可以发送,但我们还没有完全解决 SSL 问题。我们在 Heroku 中有一张支持票。但我希望至少这将帮助您更好地了解您可能需要更改哪些内容才能让 sidekiq 最初工作。
最后一点:我们了解到 RedisToGo 仅适用于 Redis 4 或其他版本。所以如果你想使用sidekiq,你不能使用RedisToGo,因为它显然不适用于Redis 4。你需要使用Heroku Redis。这是我们所做的另一项更改,它允许 sidekiq 投入生产。