From dde25c13a8ce4685003fa68832b1d2c025ed1a3f Mon Sep 17 00:00:00 2001 From: Robbe Van Petegem Date: Sat, 9 Sep 2023 14:52:09 +0200 Subject: [PATCH] Remove `Delayed::Job` --- Gemfile | 4 --- Gemfile.lock | 9 ----- bin/delayed_job | 5 --- config/initializers/delayed_job.rb | 16 --------- .../20230910071837_drop_delayed_jobs_table.rb | 24 ++++++++++++++ db/schema.rb | 18 +--------- gemset.nix | 33 ------------------- 7 files changed, 25 insertions(+), 84 deletions(-) delete mode 100755 bin/delayed_job delete mode 100644 config/initializers/delayed_job.rb create mode 100644 db/migrate/20230910071837_drop_delayed_jobs_table.rb diff --git a/Gemfile b/Gemfile index 5f85ebf1..901276d9 100644 --- a/Gemfile +++ b/Gemfile @@ -15,10 +15,6 @@ gem 'active_model_serializers', '~> 0.10' # Use ActiveModel has_secure_password gem 'bcrypt', '~> 3.1' -gem 'delayed_job_active_record', '~> 4.1' - -gem 'delayed_cron_job', '~> 0.9' - # Use GoodJob as our Active Job queue adapter gem 'good_job', '~> 3.18' diff --git a/Gemfile.lock b/Gemfile.lock index 19aa1917..e0842dba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,13 +90,6 @@ GEM debug (1.8.0) irb (>= 1.5.0) reline (>= 0.3.1) - delayed_cron_job (0.9.0) - fugit (>= 1.5) - delayed_job (4.1.11) - activesupport (>= 3.0, < 8.0) - delayed_job_active_record (4.1.7) - activerecord (>= 3.0, < 8.0) - delayed_job (>= 3.0, < 5) docile (1.4.0) erubi (1.12.0) et-orbi (1.2.7) @@ -273,8 +266,6 @@ DEPENDENCIES bootsnap (~> 1.16.0) codecov (~> 0.6.0) debug (~> 1.8) - delayed_cron_job (~> 0.9) - delayed_job_active_record (~> 4.1) factory_bot_rails (~> 6.2) faker (~> 3.2) good_job (~> 3.18) diff --git a/bin/delayed_job b/bin/delayed_job deleted file mode 100755 index edf19598..00000000 --- a/bin/delayed_job +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) -require 'delayed/command' -Delayed::Command.new(ARGV).daemonize diff --git a/config/initializers/delayed_job.rb b/config/initializers/delayed_job.rb deleted file mode 100644 index 7d36492d..00000000 --- a/config/initializers/delayed_job.rb +++ /dev/null @@ -1,16 +0,0 @@ -Delayed::Worker.destroy_failed_jobs = true -Delayed::Worker.max_attempts = 1 -Delayed::Worker.max_run_time = 1.day -Delayed::Worker.raise_signal_exceptions = :term -Delayed::Worker.logger = if ENV['RAILS_LOG_TO_STDOUT'].present? - Logger.new($stdout) - else - Logger.new(Rails.root.join("log/delayed_job_#{Rails.env}.log")) - end -Delayed::Worker.queue_attributes = { - transcodes: { priority: 5 }, - rescans: { priority: 10 }, - content_lengths: { priority: 20 }, - content_lengths_backlog: { priority: 25 }, - transcode_cache_cleaner: { priority: 100 } -} diff --git a/db/migrate/20230910071837_drop_delayed_jobs_table.rb b/db/migrate/20230910071837_drop_delayed_jobs_table.rb new file mode 100644 index 00000000..0b436a68 --- /dev/null +++ b/db/migrate/20230910071837_drop_delayed_jobs_table.rb @@ -0,0 +1,24 @@ +class DropDelayedJobsTable < ActiveRecord::Migration[7.0] + def up + drop_table :delayed_jobs + end + + def down + create_table :delayed_jobs, force: true do |table| + table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue + table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually. + table.text :handler, null: false # YAML-encoded string of the object that will do work + table.text :last_error # reason for last failure (See Note below) + table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. + table.datetime :locked_at # Set when a client is working on this object + table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) + table.string :locked_by # Who is working on this object (if locked) + table.string :queue # The name of the queue this job is in + table.timestamps null: true + + table.string :cron + end + + add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority" + end +end diff --git a/db/schema.rb b/db/schema.rb index 62f0d2a9..6796e0da 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_09_125247) do +ActiveRecord::Schema[7.0].define(version: 2023_09_10_071837) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -139,22 +139,6 @@ t.index ["filename"], name: "index_cover_filenames_on_filename", unique: true end - create_table "delayed_jobs", force: :cascade do |t| - t.integer "priority", default: 0, null: false - t.integer "attempts", default: 0, null: false - t.text "handler", null: false - t.text "last_error" - t.datetime "run_at", precision: nil - t.datetime "locked_at", precision: nil - t.datetime "failed_at", precision: nil - t.string "locked_by" - t.string "queue" - t.datetime "created_at", precision: nil - t.datetime "updated_at", precision: nil - t.string "cron" - t.index ["priority", "run_at"], name: "delayed_jobs_priority" - end - create_table "genres", force: :cascade do |t| t.string "name", null: false t.string "normalized_name", null: false diff --git a/gemset.nix b/gemset.nix index f9f9c2fa..f557ede1 100644 --- a/gemset.nix +++ b/gemset.nix @@ -256,39 +256,6 @@ }; version = "1.8.0"; }; - delayed_cron_job = { - dependencies = ["fugit"]; - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "0vq865hbld0qinzflzknbxzh3mji2swzfvdwlmgr96pdw990qrgj"; - type = "gem"; - }; - version = "0.9.0"; - }; - delayed_job = { - dependencies = ["activesupport"]; - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "0s2xg72ljg4cwmr05zi67vcyz8zib46gvvf7rmrdhsyq387m2qcq"; - type = "gem"; - }; - version = "4.1.11"; - }; - delayed_job_active_record = { - dependencies = ["activerecord" "delayed_job"]; - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "0wh1146hg0b85zv336dn00jx9mzw5ma0maj67is7bvz5l35hd6yk"; - type = "gem"; - }; - version = "4.1.7"; - }; docile = { groups = ["default" "test"]; platforms = [];