From 4d77e7c1e92055c2133595e509c09003a4837c8a Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Fri, 9 Jul 2021 14:26:58 -0400 Subject: [PATCH] Delay DUS scripts via WORKERS_DATA_UPDATE_DELAY_SECONDS in rake otherwise default run them immediately (#14166) * Allow DATA_UPDATE_WORKER_DELAY to be set otherwise run DataUpdateScripts immediately in the background * update var name and comment * set a heroku friendly default * Update ENV variable name --- lib/tasks/data_updates.rake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/tasks/data_updates.rake b/lib/tasks/data_updates.rake index 18a96bb60..11a21ef04 100644 --- a/lib/tasks/data_updates.rake +++ b/lib/tasks/data_updates.rake @@ -4,8 +4,15 @@ namespace :data_updates do if Rails.env.development? Rake::Task["data_updates:run"].execute else - # Ensure new code has been deployed before we run our update scripts - DataUpdateWorker.perform_in(10.minutes) + # @mstruve: Due to many folks already hosting their Forems on Heroku lets + # set a friendly default for them. Ideally we get everyone to use + # the ENV variable below but until we can do a hard cut over with + # a version I think this is a good compromise + default_delay = ENV["HEROKU_SLUG_COMMIT"].present? ? 10.minutes : 0 + + # Use the env variable to delay running data update scripts if your + # deploy strategy requires it + DataUpdateWorker.perform_in(ENV["WORKERS_DATA_UPDATE_DELAY_SECONDS"] || default_delay) end end