Skip to content

Commit

Permalink
Remove inline background jobs
Browse files Browse the repository at this point in the history
This isn't working correctly, as internal ActiveStorage Jobs are not run
correctly. While we could configure:

  Rails.application.config.active_job.queue_adapter = :inline

This still doesn't seem to run all jobs inline, for example the purge
jobs are never executed resulting in old attachments left in storage.
  • Loading branch information
gbp committed Sep 28, 2023
1 parent 60cde68 commit ad04d4e
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 32 deletions.
5 changes: 0 additions & 5 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@ class ApplicationJob < ActiveJob::Base # :nodoc:
# Most jobs are safe to ignore if the underlying records are no longer
# available
discard_on ActiveJob::DeserializationError

def self.perform_later(*args)
return super unless AlaveteliConfiguration.background_jobs == 'inline'
perform_now(*args)
end
end
16 changes: 0 additions & 16 deletions config/general.yml-example
Original file line number Diff line number Diff line change
Expand Up @@ -1304,19 +1304,3 @@ SURVEY_URL: ''
#
# ---
USER_SIGN_IN_ACTIVITY_RETENTION_DAYS: 0

# Background jobs are processed by Rails' ActiveJob using Sidekiq. There are
# various ways to run Sidekiq depending to server resources and technical
# knowledge in order to run and maintain a Redis server.
#
# Can either be set to:
# - 'inline' to process jobs within the web application process, this was the
# default option up until Alaveteli 0.42 and doesn't require Redis to be.
# installed. Due to issues with requests with web requests timing out this has
# been superseded by the other options.
# - 'server' to process job by a server running as a system daemon.
#
# BACKGROUND_JOBS – String (default: 'server')
#
# ---
BACKGROUND_JOBS: 'server'
2 changes: 0 additions & 2 deletions config/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,3 @@ MAX_REQUESTS_PER_USER_PER_DAY: 2
SKIP_ADMIN_AUTH: true

UTILITY_SEARCH_PATH: []

BACKGROUND_JOBS: 'server'
7 changes: 0 additions & 7 deletions lib/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module AlaveteliConfiguration
ADMIN_USERNAME: '',
AUTHORITY_MUST_RESPOND: true,
AVAILABLE_LOCALES: 'en',
BACKGROUND_JOBS: 'server',
BLACKHOLE_PREFIX: 'do-not-reply-to-this-address',
BLOCK_RATE_LIMITED_IPS: false,
BLOCK_RESTRICTED_COUNTRY_IPS: false,
Expand Down Expand Up @@ -144,12 +143,6 @@ def self.get(key, default)
value || MySociety::Config.get(key, default)
end

def self.background_jobs
value = get('BACKGROUND_JOBS', DEFAULTS[:BACKGROUND_JOBS])
return value if %w[inline server].include?(value)
raise 'Unknown value for BACKGROUND_JOBS. Please check config/general.yml'
end

def self.method_missing(name)
key = name.to_s.upcase
if DEFAULTS.key?(key.to_sym)
Expand Down
3 changes: 1 addition & 2 deletions lib/tasks/config_files.rake
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ namespace :config_files do
{
path: '/etc/systemd/system',
name: 'sidekiq.service',
template: 'config/sidekiq.service.example',
condition: -> { AlaveteliConfiguration.background_jobs == 'server' }
template: 'config/sidekiq.service.example'
}
]
end
Expand Down

0 comments on commit ad04d4e

Please sign in to comment.