diff --git a/Gemfile b/Gemfile index 1aa5d1c69..71a602997 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,9 @@ gem "resque", "~> 2.0" gem "resque-pool" gem "resque-heroku-signals" # gah, weirdly needed for graceful shutdown on heroku. https://github.com/resque/resque#heroku +# job queue +gem 'good_job' + gem 'honeybadger', '~> 4.0' # Until we get things working under sprockets 4, lock to sprockets 3 diff --git a/Gemfile.lock b/Gemfile.lock index 5b602bace..802f4fb5f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -185,6 +185,8 @@ GEM faraday (~> 1.0) oauth2 (~> 1.1) erubi (1.10.0) + et-orbi (1.2.5) + tzinfo ethon (0.14.0) ffi (>= 1.15.0) execjs (2.8.1) @@ -222,6 +224,9 @@ GEM rake font-awesome-rails (4.7.0.7) railties (>= 3.2, < 7) + fugit (1.5.2) + et-orbi (~> 1.1, >= 1.1.8) + raabro (~> 1.4) fx (0.6.2) activerecord (>= 4.0.0) railties (>= 4.0.0) @@ -229,6 +234,14 @@ GEM geocoder (1.6.7) globalid (0.5.2) activesupport (>= 5.0) + good_job (2.4.1) + activejob (>= 5.2.0) + activerecord (>= 5.2.0) + concurrent-ruby (>= 1.0.2) + fugit (>= 1.1) + railties (>= 5.2.0) + thor (>= 0.14.1) + zeitwerk (>= 2.0) google-api-client (0.53.0) google-apis-core (~> 0.1) google-apis-generator (~> 0.1) @@ -421,6 +434,7 @@ GEM nokogiri (~> 1.6) rails (>= 5.0, < 6.2) rdf + raabro (1.4.0) racc (1.5.2) rack (2.2.3) rack-protection (2.1.0) @@ -679,6 +693,7 @@ DEPENDENCIES factory_bot_rails faster_s3_url (< 2) font-awesome-rails (~> 4.7) + good_job hirefire-resource honeybadger (~> 4.0) html_aware_truncation (~> 1.0) diff --git a/Procfile b/Procfile index 7e9fe303e..f0f115a74 100644 --- a/Procfile +++ b/Procfile @@ -2,7 +2,7 @@ web: bundle exec puma -C config/heroku_puma.rb -worker: bundle exec resque-pool +worker: bundle exec good_job start # https://devcenter.heroku.com/articles/release-phase release: bundle exec rake scihist:heroku:on_release diff --git a/config/environments/production.rb b/config/environments/production.rb index 13b3fadcf..56d9b462a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -77,7 +77,8 @@ # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment) - config.active_job.queue_adapter = :resque + # config.active_job.queue_adapter = :resque + config.active_job.queue_adapter = :good_job # We are not sharing a redis among multiple apps, seems no need to queue_name_prefix, # and it makes it confusing when trying to set resque workers to work specific diff --git a/db/migrate/20211013184612_create_good_jobs.rb b/db/migrate/20211013184612_create_good_jobs.rb new file mode 100644 index 000000000..fdd772ccc --- /dev/null +++ b/db/migrate/20211013184612_create_good_jobs.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true +class CreateGoodJobs < ActiveRecord::Migration[5.2] + def change + enable_extension 'pgcrypto' + + create_table :good_jobs, id: :uuid do |t| + t.text :queue_name + t.integer :priority + t.jsonb :serialized_params + t.timestamp :scheduled_at + t.timestamp :performed_at + t.timestamp :finished_at + t.text :error + + t.timestamps + + t.uuid :active_job_id + t.text :concurrency_key + t.text :cron_key + t.uuid :retried_good_job_id + end + + add_index :good_jobs, :scheduled_at, where: "(finished_at IS NULL)", name: "index_good_jobs_on_scheduled_at" + add_index :good_jobs, [:queue_name, :scheduled_at], where: "(finished_at IS NULL)", name: :index_good_jobs_on_queue_name_and_scheduled_at + add_index :good_jobs, [:active_job_id, :created_at], name: :index_good_jobs_on_active_job_id_and_created_at + add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", name: :index_good_jobs_on_concurrency_key_when_unfinished + add_index :good_jobs, [:cron_key, :created_at], name: :index_good_jobs_on_cron_key_and_created_at + end +end diff --git a/db/schema.rb b/db/schema.rb index ed3d3d2d2..05ee94ba1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,9 +10,10 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_01_190230) do +ActiveRecord::Schema.define(version: 2021_10_13_184612) do # These are extensions that must be enabled in order to support this database + enable_extension "pg_stat_statements" enable_extension "pgcrypto" enable_extension "plpgsql" @@ -114,6 +115,27 @@ t.index ["checked_uri"], name: "index_fixity_checks_on_checked_uri" end + create_table "good_jobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.text "queue_name" + t.integer "priority" + t.jsonb "serialized_params" + t.datetime "scheduled_at" + t.datetime "performed_at" + t.datetime "finished_at" + t.text "error" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.uuid "active_job_id" + t.text "concurrency_key" + t.text "cron_key" + t.uuid "retried_good_job_id" + t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at" + t.index ["concurrency_key"], name: "index_good_jobs_on_concurrency_key_when_unfinished", where: "(finished_at IS NULL)" + t.index ["cron_key", "created_at"], name: "index_good_jobs_on_cron_key_and_created_at" + t.index ["queue_name", "scheduled_at"], name: "index_good_jobs_on_queue_name_and_scheduled_at", where: "(finished_at IS NULL)" + t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)" + end + create_table "interviewee_biographies", force: :cascade do |t| t.string "name", null: false t.jsonb "json_attributes" @@ -147,7 +169,7 @@ t.index ["container_id"], name: "index_kithe_model_contains_on_container_id" end - create_table "kithe_models", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "kithe_models", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.string "title", null: false t.string "type", null: false t.integer "position"