docbrown/lib/tasks/app_initializer.rake
Molly Struve cc694146e6
Optimization:Move Initialization CacheBust to Background Worker (#10311)
* Optimization:Move Initilization CacheBust to Background Worker

* lower cache bust to 5 min and then bust shell version last

* moving back to 10 min after looking at recent deploy data
2020-09-18 11:30:47 -04:00

27 lines
893 B
Ruby

namespace :app_initializer do
desc "Prepare Application on Boot Up"
task setup: :environment do
puts "\n== Preparing Elasticsearch =="
Rake::Task["search:setup"].execute
puts "\n== Preparing database =="
system("bin/rails db:prepare")
puts "\n== Updating Data =="
Rake::Task["data_updates:enqueue_data_update_worker"].execute
puts "\n== Bust Caches =="
Rake::Task["cache:enqueue_path_bust_workers"].execute
SiteConfig.health_check_token ||= SecureRandom.hex(10)
end
end
if ENV["ENABLE_HYPERSHIELD"].present?
# enhance must be passed a block here to ensure that our hypershield task
# runs AFTER db:prepare. Passing it as an argument will cause it to run BEFORE
# https://ruby-doc.org/stdlib-2.0.0/libdoc/rake/rdoc/Rake/Task.html#method-i-enhance
Rake::Task["db:prepare"].enhance do
Rake::Task["hypershield:refresh"].execute
end
end