Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/solid queue #390

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ Style/GlobalVars:
Exclude:
- "app/services/cache_store_config_service.rb"
- "config/initializers/redis.rb"
- "config/initializers/sidekiq.rb"

Style/SymbolProc:
Enabled: false
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ gem 'redis'
gem 'responders'
gem 'rqrcode'
gem 'rubyzip'
gem 'sidekiq'
gem 'sidekiq-cron'
gem 'slim-rails'
gem 'solid_queue'
gem 'stackprof'
gem 'statesman'
gem 'store_model'
Expand Down
24 changes: 8 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ GEM
country_select (10.0.1)
countries (> 5.0, < 8.0)
crass (1.0.6)
cronex (0.15.0)
tzinfo
unicode (>= 0.4.4.5)
csv (3.3.2)
database_cleaner (2.1.0)
database_cleaner-active_record (>= 2, < 3)
Expand Down Expand Up @@ -493,16 +490,6 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sidekiq (7.3.7)
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
sidekiq-cron (2.0.1)
cronex (>= 0.13.0)
fugit (~> 1.8, >= 1.11.1)
globalid (>= 1.0.1)
sidekiq (>= 6.5.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand All @@ -518,6 +505,13 @@ GEM
actionpack (>= 3.1)
railties (>= 3.1)
slim (>= 3.0, < 6.0, != 5.0.0)
solid_queue (1.1.2)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
fugit (~> 1.11.0)
railties (>= 7.1)
thor (~> 1.3.1)
sorbet-runtime (0.5.11755)
squasher (0.8.0)
stackprof (0.2.26)
Expand All @@ -540,7 +534,6 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unaccent (0.4.0)
unicode (0.4.4.5)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
Expand Down Expand Up @@ -637,10 +630,9 @@ DEPENDENCIES
ruby-lsp-rails
rubyzip
selenium-webdriver
sidekiq
sidekiq-cron
simplecov
slim-rails
solid_queue
squasher
stackprof
statesman
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Then inside the container you may run:

- `bin/rails-dev-server` to start rails server
- `bin/vite dev` to start vite dev server
- `bin/sidekiq-job-worker` to start the sidekiq worker process
- `bin/jobs` to start the active job worker process

To visit the automatically created default organization, visit <http://heimv.localhost:3000/>.

Expand Down
8 changes: 1 addition & 7 deletions app/jobs/mail_delivery_job.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# frozen_string_literal: true

class MailDeliveryJob < ActionMailer::MailDeliveryJob
retry_on Net::SMTPFatalError,
Net::SMTPAuthenticationError,
Net::ReadTimeout,
ActiveJob::DeserializationError,
Errno::ECONNREFUSED,
retry_on Net::SMTPFatalError, Net::SMTPAuthenticationError, Net::ReadTimeout, ActiveJob::DeserializationError,
wait: 30.seconds, attempts: 5
# discard_on ActiveJob::DeserializationError
sidekiq_options retry: 5
end
1 change: 0 additions & 1 deletion app/jobs/plan_b_backup_job.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

class PlanBBackupJob < ApplicationJob
sidekiq_options retry: 0
queue_as :default

def perform(*args)
Expand Down
22 changes: 10 additions & 12 deletions app/services/health_service.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# frozen_string_literal: true

require 'sidekiq/api'

class HealthService
def cache_ok?
Rails.cache.stats.present?
rescue StandardError => e
Rails.logger.error(e)
false
# Rails.cache.stats.present?
# rescue StandardError => e
# Rails.logger.error(e)
# false
end

def jobs_ok?
!Sidekiq::Stats.new.queues.nil?
rescue StandardError => e
Rails.logger.error(e)
false
# !Sidekiq::Stats.new.queues.nil?
# rescue StandardError => e
# Rails.logger.error(e)
# false
end

def db_ok?
Expand All @@ -27,8 +25,8 @@ def db_ok?

def to_h
{
cache: cache_ok?,
jobs: jobs_ok?,
# cache: cache_ok?,
# jobs: jobs_ok?,
db: db_ok?
}
end
Expand Down
6 changes: 6 additions & 0 deletions bin/jobs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

require_relative "../config/environment"
require "solid_queue/cli"

SolidQueue::Cli.start(ARGV)
2 changes: 2 additions & 0 deletions bin/rails-worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
bundle exec rake solid_queue:start
2 changes: 0 additions & 2 deletions bin/sidekiq-job-worker

This file was deleted.

2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Application < Rails::Application
# Don't generate system test files.
config.generators.system_tests = nil

config.active_job.queue_adapter = ENV.fetch('ACTIVE_JOB_QUEUE_ADAPTER', :inline)
config.active_job.queue_adapter = :solid_queue

config.redis_config = { url: ENV.fetch('REDIS_URL', nil), ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } }

Expand Down
10 changes: 7 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@

# Replace the default in-process memory cache store with a durable alternative.
# config.cache_store = :mem_cache_store

# Replace the default in-process and non-durable queuing backend for Active Job.
# config.active_job.queue_adapter = :resque
config.cache_store = CacheStoreFactory.redis(config.redis_config)

# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_name_prefix = "heimverwaltung_production"
config.active_job.queue_adapter = :solid_queue
# config.solid_queue.connects_to = { database: { writing: :queue } }

config.action_mailer.perform_caching = false

# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
config.action_mailer.raise_delivery_errors = true
Expand Down
2 changes: 0 additions & 2 deletions config/initializers/exception_notification.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

if defined?(ExceptionNotification)
require 'exception_notification/sidekiq'

Rails.application.config.middleware.use ExceptionNotification::Rack,
email: {
sender_address: ENV.fetch('MAIL_FROM', nil),
Expand Down
4 changes: 0 additions & 4 deletions config/initializers/sidekiq.rb

This file was deleted.

18 changes: 18 additions & 0 deletions config/queue.yml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions config/recurring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# production:
# periodic_cleanup:
# class: CleanSoftDeletedRecordsJob
# queue: background
# args: [ 1000, { batch_size: 500 } ]
# schedule: every hour
# periodic_command:
# command: "SoftDeletedRecord.due.delete_all"
# priority: 2
# schedule: at 5am every day

development:
transition_booking_states:
schedule: "0 * * * *"
class: TransitionBookingStatesJob

# test:
# <<: *default

production:
transition_booking_states:
schedule: "*/5 * * * *"
class: TransitionBookingStatesJob

clean_data_digests:
schedule: "0 3 * * *"
class: CleanDataDigestsJob

schedule_plan_b_backups:
schedule: "0 2 * * *"
class: SchedulePlanBBackupsJob
16 changes: 0 additions & 16 deletions config/schedule.yml

This file was deleted.

18 changes: 18 additions & 0 deletions config/solid_queue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#default: &default
# dispatchers:
# - polling_interval: 1
# batch_size: 500
# workers:
# - queues: "*"
# threads: 5
# processes: 1
# polling_interval: 0.1
#
# development:
# <<: *default
#
# test:
# <<: *default
#
# production:
# <<: *default
Loading
Loading