diff --git a/.ruby-version b/.ruby-version index 7bde84d..f13c6f4 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.1.2 +ruby-3.3.5 diff --git a/Dockerfile b/Dockerfile index 7db5bd5..3dbf7ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.1.2-alpine AS builder +FROM ruby:3.3.5-alpine AS builder RUN apk add build-base libpq-dev tzdata WORKDIR /app @@ -7,7 +7,7 @@ RUN bundle ADD . ./ -FROM ruby:3.1.2-alpine +FROM ruby:3.3.5-alpine RUN apk add libpq tzdata COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ diff --git a/Gemfile b/Gemfile index eb4f6ba..ffd5152 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "3.1.2" +ruby "3.3.5" gem "bootsnap", require: false gem "clearance" @@ -14,7 +14,7 @@ gem "pg", "~> 1.1" gem "propshaft" gem "puma", "~> 6.0" gem "pundit" -gem "rails", "~> 7.1" +gem "rails", "~> 7.2" gem "ransack" gem "rubyzip" gem "solid_queue" diff --git a/Gemfile.lock b/Gemfile.lock index 276b0fa..0d88215 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,91 +1,89 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) + actioncable (7.2.2) + actionpack (= 7.2.2) + activesupport (= 7.2.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (7.2.2) + actionpack (= 7.2.2) + activejob (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) + mail (>= 2.8.0) + actionmailer (7.2.2) + actionpack (= 7.2.2) + actionview (= 7.2.2) + activejob (= 7.2.2) + activesupport (= 7.2.2) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) + actionpack (7.2.2) + actionview (= 7.2.2) + activesupport (= 7.2.2) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + useragent (~> 0.16) + actiontext (7.2.2) + actionpack (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) + actionview (7.2.2) + activesupport (= 7.2.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.3.4) - activesupport (= 7.1.3.4) + activejob (7.2.2) + activesupport (= 7.2.2) globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) + activemodel (7.2.2) + activesupport (= 7.2.2) + activerecord (7.2.2) + activemodel (= 7.2.2) + activesupport (= 7.2.2) timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) + activestorage (7.2.2) + actionpack (= 7.2.2) + activejob (= 7.2.2) + activerecord (= 7.2.2) + activesupport (= 7.2.2) marcel (~> 1.0) - activesupport (7.1.3.4) + activesupport (7.2.2) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) argon2 (2.3.0) ffi (~> 1.15) ffi-compiler (~> 1.0) base64 (0.2.0) bcrypt (3.1.20) + benchmark (0.3.0) bigdecimal (3.1.8) bindex (0.8.1) - bootsnap (1.18.3) + bootsnap (1.18.4) msgpack (~> 1.2) builder (3.3.0) - clearance (2.7.1) + clearance (2.8.0) actionmailer (>= 5.0) activemodel (>= 5.0) activerecord (>= 5.0) @@ -96,16 +94,16 @@ GEM combine_pdf (1.0.26) matrix ruby-rc4 (>= 0.1.5) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) - date (3.3.4) + date (3.4.0) debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) - dotenv (3.1.2) - dotenv-rails (3.1.2) - dotenv (= 3.1.2) + dotenv (3.1.4) + dotenv-rails (3.1.4) + dotenv (= 3.1.4) railties (>= 6.1) drb (2.2.1) email_validator (2.2.4) @@ -117,22 +115,23 @@ GEM ffi-compiler (1.3.2) ffi (>= 1.15.5) rake - fugit (1.11.0) + fugit (1.11.1) et-orbi (~> 1, >= 1.2.11) raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) - importmap-rails (2.0.1) + importmap-rails (2.0.3) actionpack (>= 6.0.0) activesupport (>= 6.0.0) railties (>= 6.0.0) io-console (0.7.2) - irb (1.13.2) + irb (1.14.1) rdoc (>= 4.0.0) reline (>= 0.4.2) - loofah (2.22.0) + logger (1.6.1) + loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -143,10 +142,9 @@ GEM marcel (1.0.4) matrix (0.4.2) mini_mime (1.1.5) - minitest (5.24.0) - msgpack (1.7.2) - mutex_m (0.2.0) - net-imap (0.4.14) + minitest (5.25.1) + msgpack (1.7.3) + net-imap (0.5.0) date net-protocol net-pop (0.1.2) @@ -155,48 +153,47 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.3) - nokogiri (1.16.6-x86_64-linux) + nio4r (2.7.4) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) - paper_trail (15.1.0) + paper_trail (15.2.0) activerecord (>= 6.1) request_store (~> 1.4) - pg (1.5.6) - propshaft (0.9.0) + pg (1.5.9) + propshaft (1.1.0) actionpack (>= 7.0.0) activesupport (>= 7.0.0) rack railties (>= 7.0.0) - psych (5.1.2) + psych (5.2.0) stringio - puma (6.4.2) + puma (6.4.3) nio4r (~> 2.0) - pundit (2.3.2) + pundit (2.4.0) activesupport (>= 3.0.0) raabro (1.4.0) - racc (1.8.0) - rack (3.1.4) + racc (1.8.1) + rack (3.1.8) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (2.1.0) + rackup (2.2.0) rack (>= 3) - webrick (~> 1.8) - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + rails (7.2.2) + actioncable (= 7.2.2) + actionmailbox (= 7.2.2) + actionmailer (= 7.2.2) + actionpack (= 7.2.2) + actiontext (= 7.2.2) + actionview (= 7.2.2) + activejob (= 7.2.2) + activemodel (= 7.2.2) + activerecord (= 7.2.2) + activestorage (= 7.2.2) + activesupport (= 7.2.2) bundler (>= 1.15.0) - railties (= 7.1.3.4) + railties (= 7.2.2) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -204,49 +201,51 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - irb + railties (7.2.2) + actionpack (= 7.2.2) + activesupport (= 7.2.2) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rake (13.2.1) - ransack (4.1.1) + ransack (4.2.1) activerecord (>= 6.1.5) activesupport (>= 6.1.5) i18n rdoc (6.7.0) psych (>= 4.0.0) - reline (0.5.9) + reline (0.5.10) io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) ruby-rc4 (0.1.5) rubyzip (2.3.2) - solid_queue (0.3.3) + securerandom (0.3.1) + solid_queue (0.9.0) activejob (>= 7.1) activerecord (>= 7.1) concurrent-ruby (>= 1.3.1) fugit (~> 1.11.0) railties (>= 7.1) - stringio (3.1.1) - thor (1.3.1) + thor (~> 1.3.1) + stringio (3.1.2) + thor (1.3.2) timecop (0.9.10) - timeout (0.4.1) + timeout (0.4.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + useragent (0.16.10) web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.16) + zeitwerk (2.6.18) PLATFORMS x86_64-linux @@ -264,7 +263,7 @@ DEPENDENCIES propshaft puma (~> 6.0) pundit - rails (~> 7.1) + rails (~> 7.2) ransack rubyzip solid_queue @@ -272,7 +271,7 @@ DEPENDENCIES web-console RUBY VERSION - ruby 3.1.2p20 + ruby 3.3.5p100 BUNDLED WITH 2.3.16 diff --git a/bin/jobs b/bin/jobs new file mode 100755 index 0000000..dcf59f3 --- /dev/null +++ b/bin/jobs @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +require_relative "../config/environment" +require "solid_queue/cli" + +SolidQueue::Cli.start(ARGV) diff --git a/config/queue.yml b/config/queue.yml new file mode 100644 index 0000000..9eace59 --- /dev/null +++ b/config/queue.yml @@ -0,0 +1,18 @@ +default: &default + dispatchers: + - polling_interval: 1 + batch_size: 500 + workers: + - queues: "*" + threads: 3 + processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %> + polling_interval: 0.1 + +development: + <<: *default + +test: + <<: *default + +production: + <<: *default diff --git a/config/recurring.yml b/config/recurring.yml new file mode 100644 index 0000000..311c00d --- /dev/null +++ b/config/recurring.yml @@ -0,0 +1,13 @@ +default: &default + sync: + class: SyncJob + schedule: every 5 minutes + #notify: + # class: NotifyJob + # schedule: every 2 hours + +development: + <<: *default + +production: + <<: *default diff --git a/config/solid_queue.yml b/config/solid_queue.yml deleted file mode 100644 index 92560f3..0000000 --- a/config/solid_queue.yml +++ /dev/null @@ -1,25 +0,0 @@ -default: &default - dispatchers: - - polling_interval: 1 - batch_size: 500 - recurring_tasks: - sync: - class: SyncJob - schedule: every 5 minutes - notify: - class: NotifyJob - schedule: every 2 hours - workers: - - queues: "*" - threads: 5 - processes: 1 - polling_interval: 0.1 - -development: - <<: *default - -test: - <<: *default - -production: - <<: *default diff --git a/db/migrate/20241107142748_create_recurring_tasks.solid_queue.rb b/db/migrate/20241107142748_create_recurring_tasks.solid_queue.rb new file mode 100644 index 0000000..507c9e7 --- /dev/null +++ b/db/migrate/20241107142748_create_recurring_tasks.solid_queue.rb @@ -0,0 +1,21 @@ +# This migration comes from solid_queue (originally 20240719134516) +class CreateRecurringTasks < ActiveRecord::Migration[7.1] + def change + create_table :solid_queue_recurring_tasks do |t| + t.string :key, null: false, index: { unique: true } + t.string :schedule, null: false + t.string :command, limit: 2048 + t.string :class_name + t.text :arguments + + t.string :queue_name + t.integer :priority, default: 0 + + t.boolean :static, default: true, index: true + + t.text :description + + t.timestamps + end + end +end diff --git a/db/migrate/20241107142808_add_name_to_processes.solid_queue.rb b/db/migrate/20241107142808_add_name_to_processes.solid_queue.rb new file mode 100644 index 0000000..d5c14cd --- /dev/null +++ b/db/migrate/20241107142808_add_name_to_processes.solid_queue.rb @@ -0,0 +1,6 @@ +# This migration comes from solid_queue (originally 20240811173327) +class AddNameToProcesses < ActiveRecord::Migration[7.1] + def change + add_column :solid_queue_processes, :name, :string + end +end diff --git a/db/migrate/20241107142809_make_name_not_null.solid_queue.rb b/db/migrate/20241107142809_make_name_not_null.solid_queue.rb new file mode 100644 index 0000000..d1dcc6b --- /dev/null +++ b/db/migrate/20241107142809_make_name_not_null.solid_queue.rb @@ -0,0 +1,17 @@ +# This migration comes from solid_queue (originally 20240813160053) +class MakeNameNotNull < ActiveRecord::Migration[7.1] + def up + SolidQueue::Process.where(name: nil).find_each do |process| + process.name ||= [ process.kind.downcase, SecureRandom.hex(10) ].join("-") + process.save! + end + + change_column :solid_queue_processes, :name, :string, null: false + add_index :solid_queue_processes, [ :name, :supervisor_id ], unique: true + end + + def down + remove_index :solid_queue_processes, [ :name, :supervisor_id ] + change_column :solid_queue_processes, :name, :string, null: false + end +end diff --git a/db/migrate/20241107142810_change_solid_queue_recurring_tasks_static_to_not_null.solid_queue.rb b/db/migrate/20241107142810_change_solid_queue_recurring_tasks_static_to_not_null.solid_queue.rb new file mode 100644 index 0000000..325320a --- /dev/null +++ b/db/migrate/20241107142810_change_solid_queue_recurring_tasks_static_to_not_null.solid_queue.rb @@ -0,0 +1,6 @@ +# This migration comes from solid_queue (originally 20240819165045) +class ChangeSolidQueueRecurringTasksStaticToNotNull < ActiveRecord::Migration[7.1] + def change + change_column_null :solid_queue_recurring_tasks, :static, false, true + end +end diff --git a/db/schema.rb b/db/schema.rb index eb7c8f8..89da3ef 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.1].define(version: 2024_03_28_101458) do +ActiveRecord::Schema[7.2].define(version: 2024_11_07_142810) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -127,7 +127,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_28_101458) do t.string "hostname" t.text "metadata" t.datetime "created_at", null: false + t.string "name", null: false t.index ["last_heartbeat_at"], name: "index_solid_queue_processes_on_last_heartbeat_at" + t.index ["name", "supervisor_id"], name: "index_solid_queue_processes_on_name_and_supervisor_id", unique: true t.index ["supervisor_id"], name: "index_solid_queue_processes_on_supervisor_id" end @@ -150,6 +152,22 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_28_101458) do t.index ["task_key", "run_at"], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true end + create_table "solid_queue_recurring_tasks", force: :cascade do |t| + t.string "key", null: false + t.string "schedule", null: false + t.string "command", limit: 2048 + t.string "class_name" + t.text "arguments" + t.string "queue_name" + t.integer "priority", default: 0 + t.boolean "static", default: true, null: false + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["key"], name: "index_solid_queue_recurring_tasks_on_key", unique: true + t.index ["static"], name: "index_solid_queue_recurring_tasks_on_static" + end + create_table "solid_queue_scheduled_executions", force: :cascade do |t| t.bigint "job_id", null: false t.string "queue_name", null: false