Skip to content

Update scheduled tasks#284

Merged
rsamoilov merged 5 commits intomainfrom
scheduled-tasks-fixes
May 6, 2026
Merged

Update scheduled tasks#284
rsamoilov merged 5 commits intomainfrom
scheduled-tasks-fixes

Conversation

@rsamoilov
Copy link
Copy Markdown
Member

This pull request refactors how singleton worker processes are selected for running periodic tasks and Redis Pub/Sub listeners, and improves the deferred task scheduler for better reliability and development ergonomics. The main changes include replacing ad-hoc lock file management with a purpose-based locking mechanism, updating scheduler logging, and enhancing code clarity.

Worker Process Selection & Locking:

  • Refactored Rage::Internal.pick_a_worker to require a purpose: argument instead of an optional lock_path, generating a unique lock file per purpose and ensuring proper lock cleanup on process exit.

Deferred Scheduler Improvements:

  • Updated Rage::Deferred::Scheduler to use the new pick_a_worker(purpose:) interface, improved logging, and added development-mode logic to reload task classes dynamically.

ref #277

rsamoilov added 4 commits May 5, 2026 15:44
update `pick_a_worker` to use the `purpose` argument instead of `lock_path` - callers shouldn't know the method's implementation details (e.g. that it uses file locks). Additionally, the code is updated to work correctly with multiple instances (e.g. different Rage apps are running on the same server on different ports) and all lock files are now stored in an array to protect from GC
@rsamoilov rsamoilov merged commit 60e547e into main May 6, 2026
11 checks passed
@rsamoilov rsamoilov deleted the scheduled-tasks-fixes branch May 6, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant