geofmureithi/apalis

Distributed scheduler via cron tasks?

Closed this issue · 2 comments

Will the cron task scheduler coordinate with multiple instances of the app? Or will I end up with duplicates?

is there a way to cancel the scheduled tasks?

Thank you!

Unfortunately no. Multiple cron instances will run multiple jobs. There are several ways to work around this:

  1. Run a separate bin for cron and then push to a backend like postgres/redis
  2. Use a distributed lock eg Redis DLM
  3. If you are using sql eg postgres, you can manually write an insert sql command and use the execution time as the jobid. Apalis uses ulid which should make it easy and would prevent conflicts.

Let me know if that helps.

Regarding cancelling scheduled tasks, you should just delete the record before its execution time. This is not possible for cron though.