run periodic jobs for all shards fixes #7722

Change-Id: I07d17c7035594aa84741388e6de1b48fc8f2a885
Reviewed-on: https://gerrit.instructure.com/9568
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
This commit is contained in:
Cody Cutrer 2012-03-22 14:59:46 -06:00
parent 6b5f44f981
commit a8b245022b
1 changed files with 34 additions and 14 deletions

View File

@ -14,31 +14,43 @@ if ActionController::Base.session_store == ActiveRecord::SessionStore
expire_after ||= 1.day
Delayed::Periodic.cron 'ActiveRecord::SessionStore::Session.delete_all', '*/5 * * * *' do
ActiveRecord::SessionStore::Session.delete_all(['updated_at < ?', expire_after.ago])
Shard.with_each_shard do
ActiveRecord::SessionStore::Session.delete_all(['updated_at < ?', expire_after.ago])
end
end
end
persistence_token_expire_after = (Setting.from_config("session_store") || {})[:expire_remember_me_after]
persistence_token_expire_after ||= 1.month
Delayed::Periodic.cron 'SessionPersistenceToken.delete_all', '35 11 * * *' do
SessionPersistenceToken.delete_all(['updated_at < ?', persistence_token_expire_after.ago])
Shard.with_each_shard do
SessionPersistenceToken.delete_all(['updated_at < ?', persistence_token_expire_after.ago])
end
end
Delayed::Periodic.cron 'ExternalFeedAggregator.process', '*/30 * * * *' do
ExternalFeedAggregator.process
Shard.with_each_shard do
ExternalFeedAggregator.process
end
end
Delayed::Periodic.cron 'SummaryMessageConsolidator.process', '*/15 * * * *' do
SummaryMessageConsolidator.process
Shard.with_each_shard do
SummaryMessageConsolidator.process
end
end
Delayed::Periodic.cron 'Attachment.process_scribd_conversion_statuses', '*/5 * * * *' do
Attachment.process_scribd_conversion_statuses
Shard.with_each_shard do
Attachment.process_scribd_conversion_statuses
end
end
Delayed::Periodic.cron 'Twitter processing', '*/15 * * * *' do
TwitterSearcher.process
TwitterUserPoller.process
Shard.with_each_shard do
TwitterSearcher.process
TwitterUserPoller.process
end
end
Delayed::Periodic.cron 'Reporting::CountsReport.process', '0 11 * * *' do
@ -46,10 +58,12 @@ Delayed::Periodic.cron 'Reporting::CountsReport.process', '0 11 * * *' do
end
Delayed::Periodic.cron 'StreamItem.destroy_stream_items', '45 11 * * *' do
# we pass false for the touch_users argument, on the assumption that these
# stream items that we delete aren't visible on the user's dashboard anymore
# anyway, so there's no need to invalidate all the caches.
StreamItem.destroy_stream_items(4.weeks.ago, false)
Shard.with_each_shard do
# we pass false for the touch_users argument, on the assumption that these
# stream items that we delete aren't visible on the user's dashboard anymore
# anyway, so there's no need to invalidate all the caches.
StreamItem.destroy_stream_items(4.weeks.ago, false)
end
end
if Mailman.config.poll_interval == 0 && Mailman.config.ignore_stdin == true
@ -61,14 +75,18 @@ end
if PageView.page_view_method == :cache
# periodically pull new page views off the cache and insert them into the db
Delayed::Periodic.cron 'PageView.process_cache_queue', '*/1 * * * *' do
PageView.process_cache_queue
Shard.with_each_shard do
PageView.process_cache_queue
end
end
end
Delayed::Periodic.cron 'ErrorReport.destroy_error_reports', '35 */1 * * *' do
cutoff = Setting.get('error_reports_retain_for', 3.months.to_s).to_i
if cutoff > 0
ErrorReport.destroy_error_reports(cutoff.ago)
Shard.with_each_shard do
ErrorReport.destroy_error_reports(cutoff.ago)
end
end
end
@ -79,5 +97,7 @@ if Delayed::Stats.enabled?
end
Delayed::Periodic.cron 'Alert.process', '30 11 * * *', :priority => Delayed::LOW_PRIORITY do
Alert.process
Shard.with_each_shard do
Alert.process
end
end