From cc681a65c804333ab3b62e2edc87b0b34efd53fa Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 25 Nov 2024 13:59:43 +0000 Subject: [PATCH] do not try to schedule jobs during asset precompilation --- config/initializers/shrine.rb | 17 ++++++++++------- config/initializers/usage_reports.rb | 2 +- docker/build.dockerfile | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/config/initializers/shrine.rb b/config/initializers/shrine.rb index 57048e9d9..078735054 100644 --- a/config/initializers/shrine.rb +++ b/config/initializers/shrine.rb @@ -11,12 +11,15 @@ nil # migrations probably haven't run yet to create library table end - begin - Sidekiq::Cron::Job.create( - name: "clear-shrine-cache", - cron: "every hour", - class: "CacheSweepJob" - ) - rescue RedisClient::CannotConnectError + unless ENV.fetch("PREPARE_APP", nil) + begin + Sidekiq::Cron::Job.create( + name: "clear-shrine-cache", + cron: "every hour", + class: "CacheSweepJob" + ) + rescue + RedisClient::CannotConnectError + end end end diff --git a/config/initializers/usage_reports.rb b/config/initializers/usage_reports.rb index 776bba136..c1f24abf0 100644 --- a/config/initializers/usage_reports.rb +++ b/config/initializers/usage_reports.rb @@ -2,6 +2,6 @@ Rails.application.config.after_initialize do # Make sure the schedule is loaded correctly - UsageReport.set_schedule! + UsageReport.set_schedule! unless ENV.fetch("PREPARE_APP", nil) rescue RedisClient::CannotConnectError end diff --git a/docker/build.dockerfile b/docker/build.dockerfile index baeb80f5c..c858f0439 100644 --- a/docker/build.dockerfile +++ b/docker/build.dockerfile @@ -27,4 +27,5 @@ RUN \ DATABASE_URL="nulldb://user:pass@localhost/db" \ SECRET_KEY_BASE="placeholder" \ RACK_ENV="production" \ + PREPARE_APP="true" \ bundle exec rake assets:precompile