From 5108af162eb56ad6947e1486b1b1e132c2896e4b Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Thu, 28 Sep 2023 11:31:35 -0700 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8E=81=20Add=20conditional=20to=20run?= =?UTF-8?q?=20correct=20command=20for=20worker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a conditional to run the correct command for sidekiq or good_job, when running docker compose up. --- docker-compose.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0d349e7e3..dafc2446b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -176,7 +176,15 @@ services: - ghcr.io/samvera/hyku/base:latest - ghcr.io/samvera/hyku:latest - ghcr.io/samvera/hyku/worker:latest - command: bundle exec sidekiq + command: + - /bin/sh + - -c + - > + if [ "$$HYRAX_ACTIVE_JOB_QUEUE" == "good_job" ]; then + exec bundle exec good_job start + else + exec bundle exec sidekiq + fi depends_on: check_volumes: condition: service_completed_successfully From 35526646c157b5f2ea489f78ddb825c0e25cc245 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Tue, 3 Oct 2023 11:26:46 -0400 Subject: [PATCH 2/3] fix job loading when selecting good job --- config/initializers/apartment.rb | 2 +- .../20230406183810_setup_good_jobs_schema.rb | 16 ++++++++++++++++ db/schema.rb | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230406183810_setup_good_jobs_schema.rb diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb index a2647571d..53934a77b 100644 --- a/config/initializers/apartment.rb +++ b/config/initializers/apartment.rb @@ -12,7 +12,7 @@ # Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace. # A typical example would be a Customer or Tenant model that stores each Tenant's information. - config.excluded_models = %w{ Account AccountCrossSearch DomainName Endpoint User UserStat SolrEndpoint FcrepoEndpoint RedisEndpoint } + config.excluded_models = %w{ Account AccountCrossSearch DomainName Endpoint User UserStat SolrEndpoint FcrepoEndpoint RedisEndpoint GoodJob::Execution GoodJob::Job GoodJob::Process } # In order to migrate all of your Tenants you need to provide a list of Tenant names to Apartment. # You can make this dynamic by providing a Proc object to be called on migrations. diff --git a/db/migrate/20230406183810_setup_good_jobs_schema.rb b/db/migrate/20230406183810_setup_good_jobs_schema.rb new file mode 100644 index 000000000..5ffdffee0 --- /dev/null +++ b/db/migrate/20230406183810_setup_good_jobs_schema.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# This migration pre-sets the shared_extensions schema for in prep for good_jobs +class SetupGoodJobsSchema < ActiveRecord::Migration[5.2] + def change + # Create Schema + ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;' + # Enable Hstore + ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS HSTORE SCHEMA shared_extensions;' + # Enable UUID-OSSP + ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;' + ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "pgcrypto" SCHEMA shared_extensions;' + # Grant usage to public + ActiveRecord::Base.connection.execute 'GRANT usage ON SCHEMA shared_extensions to public;' + end +end diff --git a/db/schema.rb b/db/schema.rb index c523cfd22..c2b964beb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,8 +13,10 @@ ActiveRecord::Schema.define(version: 2023_08_04_073106) do # These are extensions that must be enabled in order to support this database + enable_extension "hstore" enable_extension "pgcrypto" enable_extension "plpgsql" + enable_extension "uuid-ossp" create_table "account_cross_searches", force: :cascade do |t| t.bigint "search_account_id" From 64d9281acf8362d4eb8e99c4ae64e5c1e9128684 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Tue, 3 Oct 2023 11:29:05 -0400 Subject: [PATCH 3/3] adjust docker compose to use the startup script --- docker-compose.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index dafc2446b..512e9bf4b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -135,7 +135,7 @@ services: web: <<: *app - # Uncomment command to access container with out starting Rails. Useful for debugging + # Uncomment command to access container with out starting bin/web. Useful for debugging # command: sleep infinity environment: - VIRTUAL_PORT=3000 @@ -167,6 +167,8 @@ services: worker: <<: *app image: ghcr.io/samvera/hyku/worker:${TAG:-latest} + # Uncomment command to access container with out starting bin/worker. Useful for debugging + # command: sleep infinity build: context: . target: hyku-worker @@ -176,15 +178,6 @@ services: - ghcr.io/samvera/hyku/base:latest - ghcr.io/samvera/hyku:latest - ghcr.io/samvera/hyku/worker:latest - command: - - /bin/sh - - -c - - > - if [ "$$HYRAX_ACTIVE_JOB_QUEUE" == "good_job" ]; then - exec bundle exec good_job start - else - exec bundle exec sidekiq - fi depends_on: check_volumes: condition: service_completed_successfully