FEATURE: warn about sidekiq overload prior to migrating

Also makes pre-flight check ensure there is no giant backlog of posts that
need to be cooked
This commit is contained in:
Sam Saffron 2019-05-22 10:04:33 +10:00
parent 5fdc7b7ca2
commit a2428bd862
1 changed files with 10 additions and 0 deletions

View File

@ -246,6 +246,10 @@ def migration_successful?(db, should_raise = false)
count = Post.where('baked_version <> ? OR baked_version IS NULL', Post::BAKED_VERSION).count
if count > 0
puts "#{count} posts still require rebaking and will be rebaked during regular job"
if count > 100
puts "To speed up migrations of posts we recommend you run 'rake posts:rebake_uncooked_posts'"
end
success = false
else
puts "No posts require rebaking"
end
@ -260,6 +264,12 @@ task "uploads:s3_migration_status" => :environment do
success &&= migration_successful?(db)
end
queued_jobs = Sidekiq::Stats.new.queues.sum { |_ , x| x }
if queued_jobs > 50
puts "WARNING: There are #{queued_jobs} jobs queued! Wait till Sidekiq clears backlog prior to migrating site to a new host"
exit 1
end
exit 1 if !success
puts "All sites appear to have uploads in order!"