Merge pull request #6801 from ivanscinote/SCI-9865-ik

Make scheduler run only on worker [SCI-9865]
This commit is contained in:
Martin Artnik 2023-12-12 11:01:20 +01:00 committed by GitHub
commit b1492ff0ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,33 +2,35 @@
require 'rufus-scheduler' require 'rufus-scheduler'
scheduler = Rufus::Scheduler.singleton if ENV['WORKER'].present?
scheduler = Rufus::Scheduler.singleton
if ENV['ENABLE_TEMPLATES_SYNC'] == 'true' if ENV['ENABLE_TEMPLATES_SYNC'] == 'true'
# Templates sync periodic task # Templates sync periodic task
scheduler.every '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(
"Templates, total number of updated projects: #{updated} out of #{total}}" "Templates, total number of updated projects: #{updated} out of #{total}}"
) )
Rails.logger.flush Rails.logger.flush
end
end
if ENV['ENABLE_FLUICS_SYNC'] == 'true'
scheduler.every '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
MyModules::DueDateReminderJob.perform_now
RepositoryItemDateReminderJob.perform_now
end
scheduler.every '1d' do
NotificationCleanupJob.perform_now
end end
end end
if ENV['ENABLE_FLUICS_SYNC'] == 'true'
scheduler.every '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
MyModules::DueDateReminderJob.perform_now
RepositoryItemDateReminderJob.perform_now
end
scheduler.every '1d' do
NotificationCleanupJob.perform_now
end