today_ai_weather/config/initializers/schedule_tasks.rb
songtianlun 1ca468f9af 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.
2025-01-25 11:05:53 +08:00

12 lines
378 B
Ruby

# config/initializers/schedule_tasks.rb
Rails.application.config.after_initialize do
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