fix: improve error handling for sitemap task
- Add error handling when scheduling the RefreshSitemapWorker in production. - Log successful scheduling and errors for improved diagnostics. This change ensures that any issues with scheduling the worker are logged and can be addressed promptly, enhancing the reliability of the application in production.
This commit is contained in:
parent
1f35664590
commit
1ca468f9af
@ -1,4 +1,11 @@
|
||||
# config/initializers/schedule_tasks.rb
|
||||
Rails.application.config.after_initialize do
|
||||
RefreshSitemapWorker.perform_async unless Rails.env.production? && !ENV["RAILS_BUILD"]
|
||||
if Rails.env.production? && !ENV["RAILS_BUILD"]
|
||||
begin
|
||||
RefreshSitemapWorker.perform_async
|
||||
Rails.logger.info "Startup task (RefreshSitemapWorker) scheduled successfully"
|
||||
rescue => e
|
||||
Rails.logger.error "Error scheduling startup task: #{e.message}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user