Jobs migration from Heroku

Hi,

We’re moving our Phoenix app from Heroku to Render. We have > 20 different jobs running throughout the day (once an hour, once a day, etc).

They all share the same codebase.

If I understand the docs correctly, for each new commit on master, Render builds 20 different new versions, one for each cron job?

Also what happens when a job is running and a new commit is pushed?

Thanks,

1 Like

If I understand the docs correctly, for each new commit on master, Render builds 20 different new versions, one for each cron job?

Can you link to the section of our docs you’re referencing? Each new commit should be one new version of your app, and should include anything within your app infrastructure such as cronjobs.

I’d expect the new commit to immediately start a new deploy of your app in Render, regardless of what your app is currently doing, but will confirm with our team.

Thanks for your answer Aaron.

Here’s the section I’m referencing:

For example, if I create 20 cron jobs from the same GitHub repo and there’s a new commit on this repo. This will trigger 20 distinct builds, correct ?

What we’d love to have is a single build shared by all cron jobs, as there are all from the same repo.

Hope this helps.

1 Like

Thanks for clarifying that part. As for your first question, the executing cron job will continue while the new code is being pushed to the service

If you have 20 cron jobs that are attached to the same repo, a single push to your repo would trigger just one new build in Render. That build would not automatically kick off all 20 cron jobs, they will only run on their scheduled run times. When they do run on schedule, they will have the newest instance of your repo’s code available. Their schedule would not be interrupted by a push to your repo, even if they all use the same repo. Does that help?

Can’t this be achieved via a sidekiq addon such as:

Or:

I think most workers have scheduling addons that could replicate cron job and scheduling.

I have the same question really. I have just migrated from Heroku and have a cron job that runs on the back of Sidekiq Cron and trying to get it to work but it doesn’t seem to pick it up at all. Any ideas?

Yes I got it working pretty easily using the sidekiq-scheduler gem above (looks like sidekiq-cron is losing interest).

Just make sure that if you have your sidekiq-cron job in a separate queue that your start command for the worker service includes that queue.

Also I’d follow the general setup guide for the gem, since they need to be included in the sidekiq.rb initializer.

Thanks for the response! Did you have to create a new cron container for it (and have your code deployed separately) or just added as part of the main worker container?

Didn’t use a cron container/job at all, it’s all part of the worker service. I’m using sidekiq-scheduler and when sidekiq is initialized it checks config/initializers/sidekiq.rb and in there you can tell it to load a schedule (as long as you are using the scheduler gem), here’s what’s in my config file:

Sidekiq.configure_server do |config|
  config.on(:startup) do
    schedule_file = Rails.root.join("config", "sidekiq_cron_schedule.yml")

    if File.exists?(schedule_file)
      Sidekiq.schedule = YAML.load_file(schedule_file)
      SidekiqScheduler::Scheduler.instance.reload_schedule!
    end
  end
end

And then in the config/sidekiq_cron_schedule.yml I have (basically):

SomeWorker:
  cron: "*/10 * * * *"
  queue: scheduler

Then my start command for the Render sidekiq background worker is:

bundle exec sidekiq -q default -q mailers -q scheduler

Thank you! That was extremely helpful!