custom_announcement scheduler 加 lockfile 避免每個 worker 重複執行,改為行程內直接刪除預覽資料,恢復 rake/console 保護條件

This commit is contained in:
rulingcom 2026-10-08 10:23:46 +08:00
parent 8ec5d8a187
commit 9733317e48
1 changed files with 5 additions and 5 deletions

View File

@ -1,9 +1,9 @@
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new
unless defined?(Rails::Console) || Rails.env.test? || File.split($0).last == 'rake'
scheduler = Rufus::Scheduler.new(lockfile: Rails.root.join('tmp', 'custom_bulletin_scheduler.lock').to_s)
#return if defined?(Rails::Console) || Rails.env.test? || File.split($0).last == 'rake'
scheduler.cron '43 2 * * *' do
system('bundle exec rake custom_bulletin:remove_preview_custom_bulletins')
scheduler.cron '43 2 * * *' do
CustomBulletin.where(is_preview: true).destroy_all
end
end