mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-04 19:53:19 +08:00
Merge pull request #7429 from ivanscinote/SCI-10581-ik
Fix rufus jobs to release db connections after use [SCI-10581]
This commit is contained in:
commit
c35c03e5b1
2 changed files with 13 additions and 6 deletions
|
@ -299,6 +299,9 @@ Naming/VariableName:
|
|||
Naming/VariableNumber:
|
||||
EnforcedStyle: normalcase
|
||||
|
||||
Naming/BlockForwarding:
|
||||
EnforcedStyle: explicit
|
||||
|
||||
Style/WordArray:
|
||||
EnforcedStyle: percent
|
||||
MinSize: 0
|
||||
|
|
|
@ -2,12 +2,17 @@
|
|||
|
||||
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?
|
||||
scheduler = Rufus::Scheduler.singleton
|
||||
|
||||
if ENV['ENABLE_TEMPLATES_SYNC'] == 'true'
|
||||
# Templates sync periodic task
|
||||
scheduler.every '12h' do
|
||||
schedule_task(scheduler, '12h') do
|
||||
Rails.logger.info('Templates, syncing all template projects')
|
||||
updated, total = TemplatesService.new.update_all_templates
|
||||
Rails.logger.info(
|
||||
|
@ -18,19 +23,18 @@ if ENV['WORKER'].present?
|
|||
end
|
||||
|
||||
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?
|
||||
end
|
||||
end
|
||||
|
||||
reminder_job_interval = ENV['REMINDER_JOB_INTERVAL'] || '1h'
|
||||
|
||||
scheduler.every reminder_job_interval do
|
||||
schedule_task(scheduler, reminder_job_interval) do
|
||||
MyModules::DueDateReminderJob.perform_now
|
||||
RepositoryItemDateReminderJob.perform_now
|
||||
end
|
||||
|
||||
scheduler.every '1d' do
|
||||
schedule_task(scheduler, '1d') do
|
||||
NotificationCleanupJob.perform_now
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue