我在 sidekiq 中有一份工作,我通过 crontab 运行,现在我无论什么时候都执行它,我也尝试了 sidekiq-cron 和同样的错误。启动时,一切正常,但在一段时间不活动后出现错误。谁知道是什么原因请解释一下。
sidekiq 中的错误代码
2023-09-06T23:58:13.292Z pid=345687 tid=76xf ERROR: Error fetching job: Waited 7 seconds
2023-09-06T23:58:13.512Z pid=345687 tid=76xf WARN: {"_config":{"labels":"#<Set: {}>","require":".","environment":"development","concurrency":5,"timeout":25,"poll_interval_average":null,"average_scheduled_poll_interval":5,"on_complex_arguments":"raise","error_handlers":["#<Proc:0x00007faa288f6310 /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sidekiq-7.1.2/lib/sidekiq/config.rb:37 (lambda)>"],"death_handlers":[],"lifecycle_events":{"startup":[],"quiet":[],"shutdown":[],"heartbeat":[],"beat":["#<Proc:0x00007faa24b86138 /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sidekiq-7.1.2/lib/sidekiq/metrics/tracking.rb:133>"]},"dead_max_jobs":10000,"dead_timeout_in_seconds":15552000,"reloader":"#<Sidekiq::Rails::Reloader @app=OasisVpn::Application>","backtrace_cleaner":"#<Proc:0x00007faa22da5bf0 /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sidekiq-7.1.2/lib/sidekiq/rails.rb:59 (lambda)>","queues":["config","send","default"],"config_file":"./config/sidekiq.yml","tag":"rails_oasis-xray","identity":"ruvds-8q2qu:345687:e3cc59408ef3"}}
2023-09-06T23:58:13.512Z pid=345687 tid=76xf WARN: RedisClient::ReadTimeoutError: Waited 7 seconds
config/initializers/sidekiq.rb
Sidekiq.configure_client do |config|
config.redis = { url: ENV['REDIS_URL'], size: 10, network_timeout: 5 }
end
Sidekiq.configure_server do |config|
config.redis = { url: ENV['REDIS_URL'], size: 10, network_timeout: 5 }
end
sidekiq.yml
:queues:
- config
- send
- default
时间表.rb
set :output, {:error => "log/cron_error_log.log", :standard => "log/cron_log.log"}
every 6.hours do
runner "DeleteConfigsJob.perform_async"
end
由于服务器较弱且卡顿,完成工作的时间超过了默认设置的 7 秒。通过增加超时时间解决了这个问题。
:timeout: 25
:queues:
- config
- send
- default