Giter Club home page Giter Club logo

Comments (11)

elpic avatar elpic commented on May 24, 2024

Hi @andrewhavens,

How are you doing?

Is the full yaml? Or is a part of it?

Please show me how do you load that yaml.

Thanks

from sidekiq-scheduler.

andrewhavens avatar andrewhavens commented on May 24, 2024

My example YAML is only one of my jobs. I can try removing the others to narrow it down.

My initializer looks like this:

require 'sidekiq/scheduler'

Sidekiq.configure_server do |config|
  config.on(:startup) do
    Sidekiq.schedule = YAML.load_file(File.expand_path("../../../config/sidekiq_schedule.yml", __FILE__))
  end
end

It seems to be loading the schedule because it appears in the Sidekiq UI.

from sidekiq-scheduler.

andrewhavens avatar andrewhavens commented on May 24, 2024

I wonder, it is raising an error because my class extends from ActiveJob::Base?

from sidekiq-scheduler.

elpic avatar elpic commented on May 24, 2024

Could you load it from sidekiq.yml instead. I think works better that way.

from sidekiq-scheduler.

elpic avatar elpic commented on May 24, 2024

You can add a key called schedule to your sidekiq.yml like this and that will be loaded automatically

:schedule:
  job:
    every: 4h
    class: MyWorker

from sidekiq-scheduler.

andrewhavens avatar andrewhavens commented on May 24, 2024

Ah, yes, adding that to sidekiq.yml seemed to get it to work. I did not previously have a sidekiq.yml file, but I created one with the following contents:

:schedule:
  job:
    every: 30s
    class: PushNotifications::SendNotificationJob
    args: ["2c56d016-ddbd-4537-8a19-4bf4d2a2e462", "Test Notification!"]

Now the jobs are automatically running, but they are still failing for the same reason. Here is the output from the sidekiq log:

2016-01-07T23:54:55.337Z 25918 TID-oweq2fkzc INFO: Running in ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
2016-01-07T23:54:55.337Z 25918 TID-oweq2fkzc INFO: See LICENSE and the LGPL-3.0 for licensing details.
2016-01-07T23:54:55.337Z 25918 TID-oweq2fkzc INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
2016-01-07T23:54:55.338Z 25918 TID-oweq2fkzc INFO: Booting Sidekiq 4.0.2 with redis options {:url=>nil}
2016-01-07T23:54:55.350Z 25918 TID-oweq2fkzc INFO: Loading Schedule
2016-01-07T23:54:55.350Z 25918 TID-oweq2fkzc INFO: Scheduling job 
2016-01-07T23:54:55.351Z 25918 TID-oweq2fkzc INFO: Schedules Loaded
2016-01-07T23:54:55.351Z 25918 TID-oweq2fkzc INFO: Starting processing, hit Ctrl-C to stop
2016-01-07T23:55:25.614Z 25918 TID-owerpsjqk INFO: queueing PushNotifications::SendNotificationJob (job)
2016-01-07T23:55:25.615Z 25918 TID-owerpsjqk INFO: ArgumentError: Message must include a Sidekiq::Worker class, not class name: [PushNotifications::SendNotificationJob, PushNotifications::BaseJob, ActiveJob::Base, ActiveJob::Translation, ActiveJob::Logging, ActiveJob::Callbacks, ActiveSupport::Callbacks, ActiveJob::Execution, ActiveSupport::Rescuable, ActiveJob::Enqueuing, ActiveJob::QueueName, ActiveJob::QueueAdapter, ActiveJob::Core, Object, PP::ObjectMixin, ActiveSupport::Dependencies::Loadable, JSON::Ext::Generator::GeneratorMethods::Object, Kernel, BasicObject]

from sidekiq-scheduler.

andrewhavens avatar andrewhavens commented on May 24, 2024

Looks like this error comes from this line in Sidekiq: https://github.com/mperham/sidekiq/blob/6ad6a3aa330deebd76c6cf0d353f66abd3bef93b/lib/sidekiq/client.rb#L225

from sidekiq-scheduler.

andrewhavens avatar andrewhavens commented on May 24, 2024

I'm guessing it has something to do with how sidekiq-scheduler is trying to queue my ActiveJob jobs directly with Sidekiq instead of using the ActiveJob adapter: https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb

from sidekiq-scheduler.

elpic avatar elpic commented on May 24, 2024

Yes, you are right I will be working on a fix for this. Thank you.

from sidekiq-scheduler.

andrewhavens avatar andrewhavens commented on May 24, 2024

I was able to get it to run with this configuration. Not ideal, but it's a start.

Note that I did not have to pass all of the options to the wrapper job. I assume that it used some defaults. I'm not sure if wrapped is necessary either.

:schedule:
  unread_count_job:
    every: 30s
    class: ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper
    wrapped: PushNotifications::SendNotificationJob
    args:
      -
        job_class: PushNotifications::SendNotificationJob
        # job_id:     job_id,
        # queue_name: queue_name,
        # priority:   priority,
        arguments: ["533fa9ab-57e2-4c96-9b36-3f9c45ba317a", "Test Notification!"]
        # locale:     I18n.locale

from sidekiq-scheduler.

elpic avatar elpic commented on May 24, 2024

Fix on released v2.0.2.

from sidekiq-scheduler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.