-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up good_job for ActiveJob backend (#1097)
As part of slimming down the production cluster (edgi-govdata-archiving/web-monitoring-ops#45), we can use good_job to do our job queuing in Postgres rather than running a Redis instance (we still use Redis as a cache, but that is outside the cluster).
- Loading branch information
Showing
17 changed files
with
168 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,6 @@ HOST_URL='web-monitoring-db.dev' | |
# specified in config/database.yml | ||
# DATABASE_URL=postgres://user:password@localhost:5432/db-name | ||
|
||
# OPTIONAL: only set this if your Redis is at a non-standard location | ||
# REDIS_URL=redis://user:password@localhost:6379 | ||
|
||
# E-mail address to use as the "from" address | ||
MAIL_SENDER='[email protected]' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,7 @@ FROM base as import-worker | |
LABEL maintainer="[email protected]" | ||
WORKDIR /app | ||
|
||
ENV QUEUES=import,analysis | ||
ENV VERBOSE=1 | ||
|
||
CMD ["bundle", "exec", "rake", "environment", "resque:work"] | ||
CMD ["bundle", "exec", "good_job", "start"] | ||
|
||
|
||
### RAILS SERVER TARGET ### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require 'resque/tasks' | ||
require_relative 'config/application' | ||
|
||
Rails.application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
QUEUE=* VERBOSE=1 RESQUE_PRE_SHUTDOWN_TIMEOUT=10 RESQUE_TERM_TIMEOUT=10 bundle exec rake environment resque:work | ||
bundle exec good_job start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Global options | ||
GoodJob.active_record_parent_class = 'ApplicationRecord' | ||
|
||
# Application options | ||
Rails.application.configure do | ||
config.good_job.on_thread_error = ->(exception) { Sentry.capture_exception(exception) } | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobs < ActiveRecord::Migration[7.0] | ||
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.datetime :scheduled_at | ||
t.datetime :performed_at | ||
t.datetime :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 | ||
t.datetime :cron_at | ||
|
||
t.uuid :batch_id | ||
t.uuid :batch_callback_id | ||
end | ||
|
||
create_table :good_job_batches, id: :uuid do |t| | ||
t.timestamps | ||
t.text :description | ||
t.jsonb :serialized_properties | ||
t.text :on_finish | ||
t.text :on_success | ||
t.text :on_discard | ||
t.text :callback_queue_name | ||
t.integer :callback_priority | ||
t.datetime :enqueued_at | ||
t.datetime :discarded_at | ||
t.datetime :finished_at | ||
end | ||
|
||
create_table :good_job_processes, id: :uuid do |t| | ||
t.timestamps | ||
t.jsonb :state | ||
end | ||
|
||
create_table :good_job_settings, id: :uuid do |t| | ||
t.timestamps | ||
t.text :key | ||
t.jsonb :value | ||
t.index :key, unique: true | ||
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 | ||
add_index :good_jobs, [:cron_key, :cron_at], name: :index_good_jobs_on_cron_key_and_cron_at, unique: true | ||
add_index :good_jobs, [:active_job_id], name: :index_good_jobs_on_active_job_id | ||
add_index :good_jobs, [:finished_at], where: 'retried_good_job_id IS NULL AND finished_at IS NOT NULL', name: :index_good_jobs_jobs_on_finished_at | ||
add_index :good_jobs, [:priority, :created_at], order: { priority: 'DESC NULLS LAST', created_at: :asc }, | ||
where: 'finished_at IS NULL', name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished | ||
add_index :good_jobs, [:batch_id], where: 'batch_id IS NOT NULL' | ||
add_index :good_jobs, [:batch_callback_id], where: 'batch_callback_id IS NOT NULL' | ||
end | ||
end |
Oops, something went wrong.