gpt4 book ai didi

ruby-on-rails - 事情在 sidekiq 中排队但没有在 heroku 中执行

转载 作者:行者123 更新时间:2023-12-04 05:51:56 24 4
gpt4 key购买 nike

所以在用户注册之后,我做了两件事

1) 发送欢迎邮件2) 将他们的 facebook 个人资料图片更新到我的 s3

  if user.save

UpdateAvatarWorker.perform_async(user.id)


UserMailer.welcome_email(user).deliver_later unless user.email.nil?

render json: {

status: 200
}
else
render json: { errors: user.errors.messages, status: 500 }
end

现在在 sidekiq 网络用户界面中,我看到这些作业正在排队但未安排

这是我的配置

config/sidekiq.yml

development:
:concurrency: 5
production:
:concurrency: 10

config/initializers/sidekiq.rb

require 'sidekiq'
require 'sidekiq/web'

if Rails.env.production?

Sidekiq.configure_client do |config|
config.redis = { size: 2 }
end

Sidekiq.configure_server do |config|
config.redis = { size: 10 }
end

end

程序文件

web: bundle exec rails server -p $PORT
worker: bundle exec sidekiq -c 10 -v -t 25 -q default -q mailers

config/initializers/redis.rb

uri = URI.parse(ENV['REDISTOGO_URL']) || "redis://localhost:6379/"
REDIS = Redis.new(url: uri)

我在 heroku redis go 中使用迷你计划,它有 50 个到 redis 的连接


redistogo (redistogo-objective-72231) mini $9/month 创建
└─ 为REDISTOGO

工作人员似乎总是处于崩溃模式

➜  couch_bunny git:(master) heroku ps --app couchbunny
=== run: one-off processes (1)
run.9503 (Standard-1X): up 2018/03/31 17:20:00 +0530 (~ 41m ago): rails console

=== web (Standard-1X): bundle exec rails server -p $PORT (1)
web.1: up 2018/03/31 17:31:03 +0530 (~ 30m ago)

=== worker (Standard-1X): bundle exec sidekiq -c 10 -v -t 25 -q default -q mailers (1)
worker.1: crashed 2018/03/31 17:47:20 +0530 (~ 14m ago)

enter image description here

最佳答案

您通过 Sidekiq.configure_server 手动设置池大小为 10,并以 10 的并发启动 Sidekiq。在内部,Sidekiq 要求池至少有 concurrency + 2 连接,所以这就是错误的来源。

Mike suggests不要手动设置 size 选项,而是让 Sidekiq 来设置。对于 10 的并发,它会自动将池大小设置为 10 + 5 = 15

关于ruby-on-rails - 事情在 sidekiq 中排队但没有在 heroku 中执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49587788/

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