sidekiq-scheduler / sidekiq-scheduler

Lightweight job scheduler extension for Sidekiq

Home Page:https://sidekiq-scheduler.github.io/sidekiq-scheduler/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read cron value from a Setting or a RAILS variable

vipulvkp opened this issue · comments

I have a configuration as below in config/sidekiq.yml.erb

   do_some_work:
      every: '1h'
      class: 'DoSomeWork

Now I want the value of every key should change based on the environment. I have defined a variable like this Settings.do_some_work_polling_interval: 1h under config/settings/development.yml and trying to use this

    do_some_work:
      every: Settings.do_some_work_polling_interval
      class: 'DoSomeWork

But while starting sidekiq, it gives an error : not a duration "Settings.do_some_work_polling_interval"

How can I make config/sidekiq.yml.erb to read values from variables instead of hardcoding.
This is a genuine requirement as I would want to run a job with different intervals based on my environment i.e. dev, qa, staging and production

if you do something like

every: <%= Settings.do_some_work_polling_interval %>

does it work?

If you put it just a string it won't be evaluated, it needs to be in <%= %> to be evaluated, it's not even something related to sidekiq

@vipulvkp did the suggestion work?