about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-09-17 22:24:50 -0500
committermultiple creatures <dev@multiple-creature.party>2019-09-17 22:24:50 -0500
commitcc32f0f50bcd25117fae3ca32ea174558b03d97c (patch)
treea159ad3dcc58ce35c86908218f23ca547fc3cdfc /app/workers
parent7ee43869e7af50fbcfce3849c7afd4caaacc60aa (diff)
make `BatchFetchMediaWorker` emergency stoppable by setting `Rails.cache.write(stop_fetch_media_worker, true)`
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/batch_fetch_media_worker.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/workers/batch_fetch_media_worker.rb b/app/workers/batch_fetch_media_worker.rb
index c002aeee7..25f8d58bb 100644
--- a/app/workers/batch_fetch_media_worker.rb
+++ b/app/workers/batch_fetch_media_worker.rb
@@ -7,6 +7,10 @@ class BatchFetchMediaWorker
 
   def perform(media_attachment_ids)
     media_attachment_ids.each_with_index do |attachment_id, index|
+      if Rails.cache.fetch('stop_fetch_media_worker', false)
+        Rails.cache.delete('stop_fetch_media_worker')
+        break
+      end
       FetchMediaWorker.perform_async(attachment_id)
       sleep(0.5 * Sidekiq::Queue.new(:bulk).size)
     end