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

UI not loading on heroku

jonatasrancan opened this issue · comments

I have suffered this scenario https://github.com/sidekiq-scheduler/sidekiq-scheduler#suggested-setup-for-multiple-hosts-using-heroku-and-rails

So I'm following the suggestion of starting a single host for the scheduler, and here is my sidekiq initializer

# frozen_string_literal: true

Sidekiq.configure_server do |config|
  if ENV.fetch("IS_SCHEDULER", false)
    config.on(:startup) do
      Sidekiq.schedule = YAML.load_file(File.expand_path("../scheduler.yml", File.dirname(__FILE__)))
      Sidekiq::Scheduler.reload_schedule!
     end
  end

  config.redis = { url: ENV["REDIS_URL" }

  sidekiq_concurrency = config.options[:concurrency]
  pool_size = ENV["SIDEKIQ_CONCURRENCY"] || ENV["DATABASE_CONNECTION_POOL"] || sidekiq_concurrency

  config = ActiveRecord::Base.configurations[Rails.env].dup.with_indifferent_access
  config["pool"] = pool_size

  ActiveRecord::Base.establish_connection(config)
end

Sidekiq.configure_client do |config|
  config.redis = { url: ENV["REDIS_URL"] }
end

And my procfile have

sidekiq_scheduler: IS_SCHEDULER=true bundle exec sidekiq -q scheduler -c 1 -e ${RAILS_ENV:-production}

It works, the scheduler is loaded and run the jobs correctly, but the UI is empty. I couldn't reproduce this locally. Seem to happening only on heroku.

Before this setup of using IS_SCHEDULER and having a single process to handle it, the UI was loading without problem, it started just after applying this approach.

sidekiq

Did anyone had this problem before? Am I missing some other config?

Some logs in the browser inspector maybe?

Some logs in the browser inspector maybe?

Nothing, they are clear.

Some extra info

sidekiq-scheduler (4.0.2)
rails (6.1.7.6)
ruby "3.0.6"
sidekiq (6.5.8)

It's weird because the UI pulls info from Redis, so in theory it should work...

I managed to reproduce, it's the same problem from here #361

I have multiple sidekiq processes, but all of them have the same config file.
I overwrite some params on the invocation it self.

sidekiq_high_priority: bundle exec sidekiq -q high_priority -c ${SIDEKIQ_CONCURRENCY:-20} -e ${RAILS_ENV:-production}
sidekiq_medium_priority: bundle exec sidekiq -q default -c ${SIDEKIQ_CONCURRENCY:-20} -e ${RAILS_ENV:-production}
sidekiq_low_priority: bundle exec sidekiq  -q low_priority -c ${SIDEKIQ_CONCURRENCY:-20} -e ${RAILS_ENV:-production}
sidekiq_scheduler: IS_SCHEDULER=true bundle exec sidekiq -q scheduler -c 1 -e ${RAILS_ENV:-production}

@jonatasrancan I see, so if you had one config file for each process, it would be solved, I guess? https://github.com/sidekiq-scheduler/sidekiq-scheduler#notes-when-running-multiple-sidekiq-processors-on-the-same-redis

If you don't want to have multiple configs file, you could probably have 2, one with the scheduler enabled and another one with it disabled and then still do the overrides you need to do?

@marcelolx yes, this solved my problem in the end
My scheduler worker loads a custom config file, and the generic one I added the disabled option

thanks for the help