custom_announcement scheduler 未取得 lockfile 鎖時跳過排程,修正 NotRunningError 導致 worker 開機失敗無限重啟

This commit is contained in:
rulingcom 2026-10-08 11:05:29 +08:00
parent 9733317e48
commit 1f14904c65
1 changed files with 4 additions and 2 deletions

View File

@ -3,7 +3,9 @@ require 'rufus-scheduler'
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)
scheduler.cron '43 2 * * *' do
CustomBulletin.where(is_preview: true).destroy_all
if scheduler.up?
scheduler.cron '43 2 * * *' do
CustomBulletin.where(is_preview: true).destroy_all
end
end
end