Pregunta

I have a config/schedule.yml file which has cron for recurring jobs in my app. But I am not sure where/how to initialize that file? In Resque we used to initialize it in resque.rake file.

¿Fue útil?

Solución

Sidekiq is not really made for recurring jobs. Quoting from the sidekiq github wiki page:

For recurring tasks, I recommend using the clockwork or whenever gems which integrate with your system's cron to schedule tasks.

I have not used sidekiq (but other similar tools like delayed_job and pure ruby schedulers like rufus_scheduler) but a major problem with non-cron based tools is to guarantee the recurring jobs will actually be executed and only the number of times you desired to. In an typical production environment with passenger it can easily happen for all ruby process to cease (thus no execution at all) or twenty processes all trying to execute the same job.

We long switched to whenever for which it is fun writing recurring jobs and which takes care of all the hassels in adding cronjobs to your system.

If you really want a easier solution and have no need for reliable execution rufus_scheduler is an option

Otros consejos

In late 2018, there are options for cron-like (aka "periodic") job scheduling with Sidekiq.

The easiest option would be to pay for Sidekiq Enterprise which provides official support for this functionality. A cheaper option is to install https://github.com/ondrejbartas/sidekiq-cron which (as writing) is actively maintained and has over four million downloads.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top