mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 16:31:22 +08:00
Fix rufus jobs to release db connections after use [SCI-10581]
This commit is contained in:
parent
51ec7c3277
commit
cda3ce29df
2 changed files with 13 additions and 6 deletions
|
|
@ -299,6 +299,9 @@ Naming/VariableName:
|
||||||
Naming/VariableNumber:
|
Naming/VariableNumber:
|
||||||
EnforcedStyle: normalcase
|
EnforcedStyle: normalcase
|
||||||
|
|
||||||
|
Naming/BlockForwarding:
|
||||||
|
EnforcedStyle: explicit
|
||||||
|
|
||||||
Style/WordArray:
|
Style/WordArray:
|
||||||
EnforcedStyle: percent
|
EnforcedStyle: percent
|
||||||
MinSize: 0
|
MinSize: 0
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,17 @@
|
||||||
|
|
||||||
require 'rufus-scheduler'
|
require 'rufus-scheduler'
|
||||||
|
|
||||||
|
def schedule_task(scheduler, interval, &block)
|
||||||
|
scheduler.every interval do
|
||||||
|
ActiveRecord::Base.connection_pool.with_connection(&block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if ENV['WORKER'].present?
|
if ENV['WORKER'].present?
|
||||||
scheduler = Rufus::Scheduler.singleton
|
scheduler = Rufus::Scheduler.singleton
|
||||||
|
|
||||||
if ENV['ENABLE_TEMPLATES_SYNC'] == 'true'
|
if ENV['ENABLE_TEMPLATES_SYNC'] == 'true'
|
||||||
# Templates sync periodic task
|
schedule_task(scheduler, '12h') do
|
||||||
scheduler.every '12h' do
|
|
||||||
Rails.logger.info('Templates, syncing all template projects')
|
Rails.logger.info('Templates, syncing all template projects')
|
||||||
updated, total = TemplatesService.new.update_all_templates
|
updated, total = TemplatesService.new.update_all_templates
|
||||||
Rails.logger.info(
|
Rails.logger.info(
|
||||||
|
|
@ -18,19 +23,18 @@ if ENV['WORKER'].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV['ENABLE_FLUICS_SYNC'] == 'true'
|
if ENV['ENABLE_FLUICS_SYNC'] == 'true'
|
||||||
scheduler.every '24h' do
|
schedule_task(scheduler, '24h') do
|
||||||
LabelPrinters::Fluics::SyncService.new.sync_templates! if LabelPrinter.fluics.any?
|
LabelPrinters::Fluics::SyncService.new.sync_templates! if LabelPrinter.fluics.any?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
reminder_job_interval = ENV['REMINDER_JOB_INTERVAL'] || '1h'
|
reminder_job_interval = ENV['REMINDER_JOB_INTERVAL'] || '1h'
|
||||||
|
schedule_task(scheduler, reminder_job_interval) do
|
||||||
scheduler.every reminder_job_interval do
|
|
||||||
MyModules::DueDateReminderJob.perform_now
|
MyModules::DueDateReminderJob.perform_now
|
||||||
RepositoryItemDateReminderJob.perform_now
|
RepositoryItemDateReminderJob.perform_now
|
||||||
end
|
end
|
||||||
|
|
||||||
scheduler.every '1d' do
|
schedule_task(scheduler, '1d') do
|
||||||
NotificationCleanupJob.perform_now
|
NotificationCleanupJob.perform_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue