jhuckaby / Cronicle

A simple, distributed task scheduler and runner with a web based UI.
http://cronicle.net
Other
3.94k stars 391 forks source link

How to prevent two different events from running in parallel #790

Open larsblumberg opened 4 months ago

larsblumberg commented 4 months ago

Summary

Two jobs each of a different event are executed at the same time.

While it's possible to not run 2 jobs of the same event in parallel, I guess that's not yet configurable globally for all events?

Steps to reproduce the problem

  1. Schedule 2 different, long running events, at a similar time
  2. Watch the 2nd job starting although the first has not yet finished

Your Setup

Regular setup

Operating system and version?

Debian docker image

Node.js version?

v20.16.0 (LTS)

Cronicle software version?

0.9.56

Are you using a multi-server setup, or just a single server?

Single server

jhuckaby commented 4 months ago

I'm not entirely sure what you want to achieve -- like, what is your end goal:

(1) If you want to ensure that your jobs ALWAYS run exactly in sequence, one at a time, then use the Chain Reaction feature. Schedule one event to run at the desired start time, set the second event to "On Demand" (no specific time), then "chain" the first event to the second one:

Screenshot 2024-07-31 at 8 19 41 PM

(2) If you want to ensure that only one of your two jobs runs at any given time, and trigger an error if another one attempts to run while the other is running, assign both events to the same category, then edit the category (on the Admin tab) and set the Max Concurrent jobs to 1:

Screenshot 2024-07-31 at 8 18 44 PM

Hope this helps.

larsblumberg commented 3 months ago

Hi @jhuckaby , thanks for your guidance. I was actually looking for a queue per category. So that if a second scheduled event tries to run in a category, that job would wait until the previous job in the same category is done. Both are scheduled events and I want to prevent both run at the same time. It would be okay if the 2nd event which is scheduled to run after the first event would just wait for the 1st one to finish.

For now it's okay to error out the 2nd event. It's a workaround at least. Thanks again!

jhuckaby commented 3 months ago

Ah, apologies, there is no queue per category. They are only per event.

Glad you were able to find a workaround tho!