Giter Club home page Giter Club logo

sidekiq-scheduler's Introduction

sidekiq-scheduler

Sidekiq Scheduler

Gem Version Documentation

sidekiq-scheduler is an extension to Sidekiq that pushes jobs in a scheduled way, mimicking cron utility.

Note: Current branch contains work of the v5 release, if you are looking for version 2.2.*, 3.*, or 4.*, go to 2.2-stable branch / v3-stable / v4-stable.

Installation

gem install sidekiq-scheduler

Usage

Hello World

# hello-scheduler.rb

require 'sidekiq-scheduler'

class HelloWorld
  include Sidekiq::Worker

  def perform
    puts 'Hello world'
  end
end

Note: In Sidekiq v6.3 Sidekiq::Job was introduced as an alias for Sidekiq::Worker. Sidekiq::Worker has been officially deprecated in Sidekiq v7 although it still exists for backwards compatibility. It is therefore recommended to use include Sidekiq::Job in the above example unless an older version of Sidekiq is required.

# config/sidekiq.yml

:scheduler:
  :schedule:
    hello_world:
      cron: '0 * * * * *'   # Runs once per minute
      class: HelloWorld

Run sidekiq:

sidekiq -r ./hello-scheduler.rb

You'll see the following output:

2016-12-10T11:53:08.561Z 6452 TID-ovouhwvm4 INFO: Loading Schedule
2016-12-10T11:53:08.561Z 6452 TID-ovouhwvm4 INFO: Scheduling HelloWorld {"cron"=>"0 * * * * *", "class"=>"HelloWorld"}
2016-12-10T11:53:08.562Z 6452 TID-ovouhwvm4 INFO: Schedules Loaded

2016-12-10T11:54:00.212Z 6452 TID-ovoulivew HelloWorld JID-b35f36a562733fcc5e58444d INFO: start
Hello world
2016-12-10T11:54:00.213Z 6452 TID-ovoulivew HelloWorld JID-b35f36a562733fcc5e58444d INFO: done: 0.001 sec

2016-12-10T11:55:00.287Z 6452 TID-ovoulist0 HelloWorld JID-b7e2b244c258f3cd153c2494 INFO: start
Hello world
2016-12-10T11:55:00.287Z 6452 TID-ovoulist0 HelloWorld JID-b7e2b244c258f3cd153c2494 INFO: done: 0.001 sec

Configuration options

Configuration options are placed inside sidekiq.yml config file.

Available options are:

:scheduler:
  :dynamic: <if true the schedule can be modified in runtime [false by default]>
  :dynamic_every: <if dynamic is true, the schedule is reloaded every interval [5s by default]>
  :enabled: <enables scheduler if true [true by default]>
  :listened_queues_only: <push jobs whose queue is being listened by sidekiq [false by default]>
  :rufus_scheduler_options: <Set custom options for rufus scheduler, like max_work_threads [{} by default]>

Schedule configuration

The schedule is configured through the :scheduler: -> :schedule config entry in the sidekiq config file:

:scheduler:
  :schedule:
    CancelAbandonedOrders:
      cron: '0 */5 * * * *'   # Runs when second = 0, every 5 minutes

    queue_documents_for_indexing:
      cron: '0 0 * * * *'   # Runs every hour

      # By default the job name will be taken as worker class name.
      # If you want to have a different job name and class name, provide the 'class' option
      class: QueueDocuments

      queue: slow
      args: ['*.pdf']
      description: "This job queues pdf content for indexing in solr"

      # Enable the `metadata` argument which will pass a Hash containing the schedule metadata
      # as the last argument of the `perform` method. `false` by default.
      include_metadata: true

      # Enable / disable a job. All jobs are enabled by default.
      enabled: true

      # Deconstructs a hash defined as the `args` to keyword arguments. 
      #
      # `false` by default.
      # 
      # Example
      # 
      # my_job:
      #   cron: '0 0 * * * *'
      #   class: MyJob
      #   args: { foo: 'bar', hello: 'world' } 
      #   keyword_argument: true
      #
      # class MyJob < ActiveJob::Base
      #   def perform(foo:, hello:)
      #     # ...
      #   end
      # end
      keyword_argument: true 

Schedule metadata

You can configure Sidekiq-scheduler to pass an argument with metadata about the scheduling process to the worker's perform method.

In the configuration file add the following on each worker class entry:

  SampleWorker:
    include_metadata: true

On your perform method, expect an additional argument:

  def perform(args, ..., metadata)
    # Do something with the metadata
  end

The metadata hash contains the following keys:

  metadata.keys =>
    [
      :scheduled_at # The epoch when the job was scheduled to run
    ]

Schedule types

Supported types are cron, every, interval, at, in.

Cron, every, and interval types push jobs into sidekiq in a recurrent manner.

cron follows the same pattern as cron utility, with seconds resolution.

:scheduler:
  :schedule:
    HelloWorld:
      cron: '0 * * * * *' # Runs when second = 0

every triggers following a given frequency:

    every: '45m'    # Runs every 45 minutes

The value is parsed by Fugit::Duration.parse. It understands quite a number of formats, including human-readable ones:

    every: 45 minutes
    every: 2 hours and 30 minutes
    every: 1.5 hours

interval is similar to every, the difference between them is that interval type schedules the next execution after the interval has elapsed counting from its last job enqueue.

Note that every and interval count from when the Sidekiq process (re)starts. So every: '48h' will never run if the Sidekiq process is restarted daily, for example. You can do every: ['48h', first_in: '0s'] to make the job run immediately after a restart, and then have the worker check when it was last run.

At, and in types push jobs only once. at schedules in a point in time:

    at: '3001/01/01'

You can specify any string that DateTime.parse and Chronic understand. To enable Chronic strings, you must add it as a dependency.

in triggers after a time duration has elapsed:

    in: 1h # pushes a sidekiq job in 1 hour, after start-up

You can provide options to every or cron via an Array:

    every: ['30s', first_in: '120s']

See https://github.com/jmettraux/rufus-scheduler for more information.

Load the schedule from a different file

You can place the schedule configuration in a separate file from config/sidekiq.yml

# sidekiq_scheduler.yml

clear_leaderboards_contributors:
  cron: '0 30 6 * * 1'
  class: ClearLeaderboards
  queue: low
  args: contributors
  description: 'This job resets the weekly leaderboard for contributions'

Please notice that the schedule root key is not present in the separate file.

To load the schedule:

require 'sidekiq'
require 'sidekiq-scheduler'

Sidekiq.configure_server do |config|
  config.on(:startup) do
    Sidekiq.schedule = YAML.load_file(File.expand_path('../../sidekiq_scheduler.yml', __FILE__))
    SidekiqScheduler::Scheduler.instance.reload_schedule!
  end
end

The above code can be placed in an initializer (in config/initializers) that runs every time the app starts up.

Dynamic schedule

The schedule can be modified after startup. To add / update a schedule, you have to:

Sidekiq.set_schedule('heartbeat', { 'every' => ['1m'], 'class' => 'HeartbeatWorker' })

If the schedule did not exist it will be created, if it existed it will be updated.

When :dynamic flag is set to true, schedule changes are loaded every 5 seconds. Use the :dynamic_every flag for a different interval.

# config/sidekiq.yml
:scheduler:
  :dynamic: true

If :dynamic flag is set to false, you'll have to reload the schedule manually in sidekiq side:

SidekiqScheduler::Scheduler.instance.reload_schedule!

Invoke Sidekiq.get_schedule to obtain the current schedule:

Sidekiq.get_schedule
#  => { 'every' => '1m', 'class' => 'HardWorker' }

Time zones

Note that if you use the cron syntax and are not running a Rails app, this will be interpreted in the server time zone.

In a Rails app, rufus-scheduler (>= 3.3.3) will use the config.time_zone specified in Rails.

You can explicitly specify the time zone that rufus-scheduler will use:

    cron: '0 30 6 * * 1 Europe/Stockholm'

Also note that config.time_zone in Rails allows for a shorthand (e.g. "Stockholm") that rufus-scheduler does not accept. If you write code to set the scheduler time zone from the config.time_zone value, make sure it's the right format, e.g. with:

ActiveSupport::TimeZone.find_tzinfo(Rails.configuration.time_zone).name

Notes about connection pooling

If you're configuring your own Redis connection pool, you need to make sure the size is adequate to be inclusive of both Sidekiq's own connection pool and Rufus Scheduler's.

That's a minimum of concurrency + 5 (per the Sidekiq wiki) + Rufus::Scheduler::MAX_WORK_THREADS (28 as of this writing; per the Rufus README), for a total of 58 with the default concurrency of 25.

You can also override the thread pool size in Rufus Scheduler by setting the following in your sidekiq.yml config:

---
...

:scheduler:
  rufus_scheduler_options:
    max_work_threads: 5

...

Notes about running on Multiple Hosts

Under normal conditions, cron and at jobs are pushed once regardless of the number of sidekiq-scheduler running instances, assumming that time deltas between hosts is less than 24 hours.

Non-normal conditions that could push a specific job multiple times are:

every, interval and in jobs will be pushed once per host.

Suggested setup for Multiple Hosts using Heroku and Rails

Configuration options every, interval and in will push once per host. This may be undesirable. One way to achieve single jobs per the schedule would be to manually designate a host as the scheduler. The goal is to have a single scheduler process running across all your hosts.

This can be achieved by using an environment variable and controlling the number of dynos. In Rails, you can read this variable during initialization and then conditionally load your config file.

Suppose we are using Rails and have the following schedule:

# config/scheduler.yml
MyRegularJob:
  description: "We want this job to run very often, but we do not want to run more of them as we scale"
  interval: ["1m"]
  queue: default

Then we can conditionally load it via an initializer:

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

Then you would just need to flag the scheduler process when you start it. If you are using a Procfile, it would look like this:

# Procfile
web: bin/rails server
worker: bundle exec sidekiq -q default
scheduler: IS_SCHEDULER=true bundle exec sidekiq -q default

When running via Heroku, you set your scheduler process to have 1 dyno. This will ensure you have at most 1 worker loading the schedule.

Notes on when Sidekiq worker is down

For a cron/at (and all other) job to be successfully enqueued, you need at least one sidekiq worker with scheduler to be up at that moment. Handling this is up to you and depends on your application.

Possible solutions include:

  • Simply ignoring this fact, if you only run frequent periodic jobs, that can tolerate some increased interval
  • Abstaining from deploys/restarts during time when critical jobs are usually scheduled
  • Making your infrequent jobs idempotent (so that they can be enqueued multiple times but still produce result as if was run once) and scheduling them multiple times to reduce likelihood of not being run
  • Zero downtime deploy for sidekiq workers: keep at least one worker up during whole deploy and only restart/shut it down after when new one has started
  • Running scheduler inside your unicorn/rails processes (if you already have zero downtime deploy set up for these)

Each option has it's own pros and cons.

Notes when running multiple Sidekiq processors on the same Redis

TL;DR

Be sure to include the :enabled: false top-level key on any additional configurations to avoid any possibility of the schedules definition being wiped by the second Sidekiq process.

To illustrate what we mean:

Say you have one process with the schedule:

# e.g., config/sidekiq.yml

:queues:
  - default
:scheduler:
  :schedule:
    do_something_every_minute:
      class: DoSomethingJob
      args: matey
      queue: :scheduler
      cron: '0 * * * * * America/Los_Angeles'

And a separate separate configured process without one:

# e.g., config/sidekiq_other.yml
:queues:
  - scheduler

## NOTE Disable the Scheduler
:scheduler:
  :enabled: false

Details

This gem stores the configured schedule in Redis on boot. It's used, primarily, to display in the Web Integration, and allow you to interact with that schedule via that integration.

If you're running multiple Sidekiq processes on the same Redis namespace with different configurations, you'll want to explicitly disable Sidekiq Scheduler for the other processes not responsible for the schedule. If you don't, the last booted Sidekiq processes' schedule will be what is stored in Redis.

See #361 for a more details.

Notes when running multiple applications in the same Redis database

NOTE: Although we support this option, we recommend having separate redis databases for each application. Choosing this option is at your own risk.

If you need to run multiple applications with differing schedules, the easiest way is to use a different Redis database per application. Doing that will ensure that each application will have its own schedule, web interface and statistics.

However, you may want to have a set of related applications share the same Redis database in order to aggregate statistics and manage them all in a single web interface. To do this while maintaining a different schedule for each application, you can configure each application to use a different key_prefix in Redis. This prevents the applications overwriting each others' schedules and schedule data.

Rails.application.reloader.to_prepare do
  SidekiqScheduler::RedisManager.key_prefix = "my-app"
end

Note that this must be set before the schedule is loaded (or it will go into the wrong key). If you are using the web integration, make sure that the prefix is set in the web process so that you see the correct schedule.

Sidekiq Web Integration

sidekiq-scheduler provides an extension to the Sidekiq web interface that adds a Recurring Jobs page.

# config.ru

require 'sidekiq/web'
require 'sidekiq-scheduler/web'

run Sidekiq::Web

Sidekiq Web Integration

ActiveJob integration

When using sidekiq-scheduler with ActiveJob your jobs can just extend ApplicationJob as usual, without the require and include boilerplate. Under the hood Rails will load up the scheduler and include the worker module for you.

class HelloWorld < ApplicationJob
  def perform
    puts 'Hello world'
  end
end

The Spring preloader and Testing your initializer via Rails console

If you're pulling in your schedule from a YML file via an initializer as shown, be aware that the Spring application preloader included with Rails will interefere with testing via the Rails console.

Spring will not reload initializers unless the initializer is changed. Therefore, if you're making a change to your YML schedule file and reloading Rails console to see the change, Spring will make it seem like your modified schedule is not being reloaded.

To see your updated schedule, be sure to reload Spring by stopping it prior to booting the Rails console.

Run spring stop to stop Spring.

For more information, see this issue and Spring's README.

Manage tasks from Unicorn/Rails server

If you want start sidekiq-scheduler only from Unicorn/Rails, but not from sidekiq you can have something like this in an initializer:

# config/initializers/sidekiq_scheduler.rb
require 'sidekiq'
require 'sidekiq-scheduler'

puts "Sidekiq.server? is #{Sidekiq.server?.inspect}"
puts "defined?(Rails::Server) is #{defined?(Rails::Server).inspect}"
puts "defined?(Unicorn) is #{defined?(Unicorn).inspect}"

if Rails.env == 'production' && (defined?(Rails::Server) || defined?(Unicorn))
  Sidekiq.configure_server do |config|

    config.on(:startup) do
      Sidekiq.schedule = YAML.load_file(File.expand_path('../../scheduler.yml', __FILE__))
      SidekiqScheduler::Scheduler.instance.reload_schedule!
    end
  end
else
  SidekiqScheduler::Scheduler.instance.enabled = false
  puts "SidekiqScheduler::Scheduler.instance.enabled is #{SidekiqScheduler::Scheduler.instance.enabled.inspect}"
end

License

MIT License

Copyright

  • Copyright 2021 - 2023 Marcelo Lauxen.
  • Copyright 2013 - 2022 Moove-IT.
  • Copyright 2012 Morton Jonuschat.
  • Some parts copyright 2010 Ben VandenBos.

sidekiq-scheduler's People

Contributors

284km avatar abmatgit avatar adrian-gomez avatar byroot avatar cdotta avatar cih avatar dependabot[bot] avatar ecin avatar elpic avatar gian-zas avatar iamdeuterium avatar marcelolx avatar matu1104 avatar mconiglio avatar mjonuschat avatar olleolleolle avatar petergoldstein avatar prokopsimek avatar raerten avatar reneklacan avatar shayonj avatar snmgian avatar stefanahman avatar stoivo avatar t27duck avatar tallama avatar vassilevsky avatar wolfer avatar wspurgin avatar y-yagi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sidekiq-scheduler's Issues

Job is run once.

When I run following from Rails console

BasicWorker.perform_in(10.seconds, 'bob', 5)

I expect this BasicWorker runs every 10 seconds..

But I noticed it runs only once..

how to run

hi,
I'm not sure I understand if sidekiq-scheduler runs separately or together with sidekiq.

For example, do I need to run sidekiq and sidekiq-scheduler separately? or just run sidekiq-scheduler by it self and will do both jobs?

I ask because in resque we have to run both separately loading 2 copies of the application in Ram, such as:

bundle exec rake resque:work
bundle exec rake resque:scheduler

Reload Schedules

Hi

i'm using Sidekiq 3.1.4 with Sidekiq-scheduler 1.0 with Ruby 2.0 and i'm having issues Reloading my schedules. my basic sidekiq.rb looks like:

#./sidekiq.rb
Sidekiq.configure_server do |config|
config.redis = { url: 'REDIS_URL', namespace: "sidekiq" , :size => 5}
end
Dir["./myworker.rb"].each { |file| require file }
Sidekiq::Scheduler.dynamic = true
Sidekiq.schedule = YAML.load_file(File.expand_path('../schedule.yml',FILE))
#./sidekiq.yml
:concurrency: 25
:pidfile: ./sidekiq.pid
:logfile: ./sidekiq.log
:queues:
- default
- myqueue
when loading my schedule from the rakefile using "bundle exec sidekiq -r ./sidekiq.rb -C ./sidekiq.yml -d" i see on the log that it loaded the schedules and he enqueue them according to the cron arguments.

what i dont fully understand is how flexible the scheduling can be. i want to have the ability to update a job, for example argument or different cron time, and want to add additional jobs while system is running, without the need to restart sidekiq process.

found few posts that suggest to search for the jid of the job and update it, although indicate performance issues on that solution.

now i saw on the Sidekiq API that there is a method like "reload_schedule!"
i i've tried to do something like

config = {
:class => 'MyWorker',
:cron => '*/1 * * * * ',
:args => 'myargs'
}
Sidekiq.set_schedule('testSystem1',config)
Sidekiq.reload_schedule!
schedules =Sidekiq.get_all_schedules
#does show the new schedule but it doesnt really loaded it for actual work of the workers.
i though that i should see on the sidekiq.log something like "Schedule loaded" as it wrote at the startup, and now with the new addition.

any help will be appriciated.

Thanks!

Levi

Keep the tags up to date?

Hey guys, I'd love it if, as part of your deploy process you could keep the tags up to date. It's super handy for devs to be able to see the latest version without having to go to Rubygems (since we're typically looking at the README anyway).

Jobs based on fixed schedule

Allow to define scheduled jobs based on fixed schedule like ResqueScheduler do:

schedule.yml:

CancelAbandonedOrders:
  cron: "*/5 * * * *"

queue_documents_for_indexing:
  cron: "0 0 * * *"
  class: QueueDocuments
  queue: high
  args:
  description: "Job"

Somewhere in application:

Sidekiq.schedule = YAML.load_file("schedule.yml")

Please let me know if it's implemented. I looked through documentation and source code but found nothing.

Sidekiq-scheduler reload schedule

Hi

i'm using Sidekiq 3.1.4 with Sidekiq-scheduler 1.2 with Ruby 2.3 and i'm having issues Reloading my schedules.
my basic sidekiq.rb looks like:

#./sidekiq.rb
Sidekiq.configure_server do |config|
    config.redis = {  url: 'REDIS_URL', namespace: "sidekiq" , :size => 5}
end
Dir["./myworker.rb"].each { |file| require file }
Sidekiq::Scheduler.dynamic = true
Sidekiq.schedule = YAML.load_file(File.expand_path('../schedule.yml',__FILE__))

#./sidekiq.yml
:concurrency: 25
:pidfile: ./sidekiq.pid
:logfile: ./sidekiq.log
:queues:
 - default
 - myqueue

when starting sidekiq service from the rakefile using "bundle exec sidekiq -r ./sidekiq.rb -C ./sidekiq.yml -d" i see on the log that it loaded the schedules of shcedule.yml and he enqueue them according to the cron arguments.

what i dont fully understand is how flexible the scheduling can be. i want to have the ability to update a job, for example argument or different cron time, and want to add additional jobs while system is running, without the need to restart sidekiq process.

i couldnt find anything working on the net, but i'v found few methods on the sources code which seems should do the job, but still not quite sure how its really should work.

i've tried to use load_scheudle, update_scheudle and reload_schedule!
for example i've tried to do something like the following for loading additional job dynamicaly

 config =  {
     :class => 'MyWorker',
     :cron => '*/1 * * * * ',
     :args => 'myargs'
 }
 Sidekiq.set_schedule('testSystem1',config)
 Sidekiq.reload_schedule!  # and also tried with Sidekiq::Scheduler.update_schedule
 schedules =Sidekiq.get_all_schedules
 #does show the new schedule but it doesnt really loaded it for actual work of the workers.

i though that i should see on the sidekiq.log something like "Schedule loaded" as it wrote at the startup, and now with the new addition, but it didnt.

using the update_schedule sometimes just give an exception that the class of "@@scheduled_jobs" isnt initalized.

what is the right way to work with Sidekiq-scheduler?
how i can load when string the sidekiq process few jobs as we do with sidekis.schedule= and continue add additional jobs when the system is running?

any help will be appriciated.

Thanks!

Levi

Document config/sidekiq.yml syntax

The README mentions that it's possible to store the schedules in config/sidekiq.yml, but it doesn't tell you what key to use. So it would be nice to have an example.

Eg. a config might look like:

---
:concurrency: 5
:pidfile: tmp/pids/sidekiq.pid
:queues:
  - default
  - process_asset
staging:
  :concurrency: 5
  :tag: myapp_staging
  :queues:
    - default
    - export
    - process_asset
    - import
production:
  :concurrency: 25
  :tag: myapp_production
  :queues:
    - default
    - export
    - process_asset
    - import

It would make sense to be possible to define schedules like this:

---
:concurrency: 5
:pidfile: tmp/pids/sidekiq.pid
:queues:
  - default
  - process_asset
:schedules:
  AssetWorker:
    every: 15m
staging:
  :concurrency: 5
  :tag: myapp_staging
  :queues:
    - default
    - export
    - process_asset
    - import
  :schedules:
    AssetWorker:
      every: 60m
    ImportWorker:
      every: 1m
    ExportWorker:
      every: 1m
production:
  :concurrency: 25
  :tag: myapp_production
  :queues:
    - default
    - export
    - process_asset
    - import
  :schedules:
    AssetWorker:
      every: 2h
    ImportWorker:
      every: 15m
    ExportWorker:
      every: 15m

The idea is that you can define a default schedule and override per environment.

0.4.1 bug with bang-methods

Right now the released version of gem (latest on rubygems.org is 0.4.1) is broken, runner script outputs:

undefined method `start!' for #SidekiqScheduler::Manager:0x007f83f4f24c50

As i found in sidekiq-scheduler/cli.rb, there are still bang method calls:

      scheduler = SidekiqScheduler::Manager.new(scheduler_options)
      scheduler.start!
      run_manager
      scheduler.stop!

Is it possible to release fixed version 0.5 of the gem anytime soon?

Not compatible with ActiveJob: Error: Message must include a Sidekiq::Worker class

When I click the new "enqueue now" button in the UI, I get an error:

ArgumentError at /sidekiq/recurring-jobs/test_notification/enqueue
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]

The whole reason I'm trying to manually enqueue the job is because I can't get any of my recurring jobs to run at all.

Here is my configuration yaml:

test_notification:
  every: 3m
  class: PushNotifications::SendNotificationJob
  args: ["2c56d016-ddbd-4537-8a19-4bf4d2a2e462", "Test Notification!"]

I'm using the latest version of Sidekiq (4.0.2) and the latest commit on the master branch of this repo. I'm trying to test this in my development environment. So I started sidekiq with bundle exec sidekiq. The output shows:

2016-01-07T21:04:14.777Z 23500 TID-ox04q3th4 INFO: Running in ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
2016-01-07T21:04:14.777Z 23500 TID-ox04q3th4 INFO: See LICENSE and the LGPL-3.0 for licensing details.
2016-01-07T21:04:14.778Z 23500 TID-ox04q3th4 INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
2016-01-07T21:04:14.778Z 23500 TID-ox04q3th4 INFO: Booting Sidekiq 4.0.2 with redis options {:url=>nil}
2016-01-07T21:04:14.780Z 23500 TID-ox04q3th4 INFO: Loading Schedule
2016-01-07T21:04:14.780Z 23500 TID-ox04q3th4 INFO: Schedule empty! Set Sidekiq.schedule
2016-01-07T21:04:14.781Z 23500 TID-ox04q3th4 INFO: Schedules Loaded
2016-01-07T21:04:14.787Z 23500 TID-ox04q3th4 INFO: Starting processing, hit Ctrl-C to stop

Am I doing something wrong?

ActiveJob named parameters

Hello,

i try to figure-out how to pass args to ActiveJob class

for example:

Sidekiq.set_schedule('job_name', 'SomeJob', cron: '* * * * *', args: { message_id: 23121, regenerate: true } )

but in method enqueue_job is

      if defined?(ActiveJob::Enqueuing) && config['class'].included_modules.include?(ActiveJob::Enqueuing)
        config['class'].new.enqueue(config)
      else

ActiveJob::Enqueuing.enqueue doesn't accept job arguments but initialize does.

Passing config['args'] to initialize works:
Just for example:

    def self.enqueue_job(job_config)
      config = job_config.dup

      config['class'] = config['class'].constantize if config['class'].is_a?(String)
      if config['args'].is_a?(Hash)
        config['args'].symbolize_keys!
      else
        config['args'] = Array(config['args'])
      end

      if defined?(ActiveJob::Enqueuing) && config['class'].included_modules.include?(ActiveJob::Enqueuing)
        config['class'].new(config['args']).enqueue
      else
        Sidekiq::Client.push(config)
      end
    end

Scheduler giving timeout errors

Not sure if this is something with my config, but I get timeout errors in the scheduler log after it runs for a few days straight. It happened today, and beforehand it was running fine for about a week.

Today the log showed this:

2014-11-30_21:02:23.84590 2014-11-30T21:02:23.845Z 29383 TID-dr6wc INFO: queueing JobName1 ()
2014-11-30_21:02:23.84762 2014-11-30T21:02:23.846Z 29383 TID-dq2ng INFO: queueing JobName2 ()
2014-11-30_21:02:23.84803 2014-11-30T21:02:23.846Z 29383 TID-dq7ao INFO: queueing JobName3 ()
2014-11-30_21:02:23.84858 2014-11-30T21:02:23.846Z 29383 TID-dq5ew INFO: queueing JobName4 ()
2014-11-30_21:02:23.84860 2014-11-30T21:02:23.846Z 29383 TID-dq41g INFO: queueing JobName5 ()
2014-11-30_21:02:23.84884 2014-11-30T21:02:23.846Z 29383 TID-dq3bw INFO: queueing JobName6 ()
2014-11-30_21:02:23.84887 2014-11-30T21:02:23.847Z 29383 TID-dq80s INFO: queueing JobName7 ()
2014-11-30_21:02:25.84791 2014-11-30T21:02:25.847Z 29383 TID-dr6wc INFO: Timeout::Error: Waited 2 sec
2014-11-30_21:02:25.84812 2014-11-30T21:02:25.848Z 29383 TID-dq2ng INFO: Timeout::Error: Waited 2 sec
2014-11-30_21:02:25.84830 2014-11-30T21:02:25.848Z 29383 TID-dq7ao INFO: Timeout::Error: Waited 2 sec
2014-11-30_21:02:25.84884 2014-11-30T21:02:25.848Z 29383 TID-dq41g INFO: Timeout::Error: Waited 2 sec
2014-11-30_21:02:25.84885 2014-11-30T21:02:25.848Z 29383 TID-dq5ew INFO: Timeout::Error: Waited 2 sec
2014-11-30_21:02:25.84898 2014-11-30T21:02:25.848Z 29383 TID-dq3bw INFO: Timeout::Error: Waited 2 sec
2014-11-30_21:02:25.84921 2014-11-30T21:02:25.849Z 29383 TID-dq80s INFO: Timeout::Error: Waited 2 sec

I've set my sidekiq client/server connection pool size to 27, timeout to 2 seconds. Not sure what else it could be. Jobs that are manually kicked off are queueing and processed fine.

WARN: DEPRECATION WARNING: 'bang method'-style async syntax is deprecated

2013-07-26T07:58:45Z 16316 TID-8101k WARN: DEPRECATION WARNING: 'bang method'-style async syntax is deprecated and will be removed in Celluloid 1.0.Call async methods with 'actor.async.method'.
    /home/styx/.rvm/gems/ruby-2.0.0-p247/gems/celluloid-0.14.1/lib/celluloid/legacy.rb:7:in `method_missing'
    /home/styx/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-scheduler-0.4.1/lib/sidekiq-scheduler/cli.rb:24:in `run_scheduler'
    /home/styx/.rvm/gems/ruby-2.0.0-p247/gems/sidekiq-scheduler-0.4.1/bin/sidekiq-scheduler:15:in `<top (required)>'
    /home/styx/.rvm/gems/ruby-2.0.0-p247/bin/sidekiq-scheduler:23:in `load'
    /home/styx/.rvm/gems/ruby-2.0.0-p247/bin/sidekiq-scheduler:23:in `<main>'
    /home/styx/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
    /home/styx/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'

schedules in redis gets cleared immediately after set

Hi,

I am using sidekiq-scheduler and noticed a strange behaviour in web UI. the schedules were only visible for every alternative sidekiq process restarts. so if its visible for the 1st time then i would have to restart the process 2 more times to see the schedules in web UI again. The culprit seems be the following line :

https://github.com/moove-it/sidekiq-scheduler/blob/master/lib/sidekiq-scheduler/schedule.rb#L46

def schedule=(schedule_hash)
schedule_hash = prepare_schedule(schedule_hash)
to_remove = (get_all_schedules || {}).keys - schedule_hash.keys

  schedule_hash.each do |name, job_spec|
    set_schedule(name, job_spec)
  end

  to_remove.each do |name|
    remove_schedule(name)
  end

  @schedule = schedule_hash
end

The schedules are removed after they are added to the redis. It happens alternatively because the second time they are cleared making the way for third start to set it properly. If this is the correct approach then i am assuming the schedules should have been properly cleared when the sidekiq exited.

Can you please point out if this issue is genuine or if my understanding is wrong.

Thanks,
Vikram

Jobs not displayed in web ui

my schedule in config/sidekiq.yml

:schedule:
  authenticom_daily_files_import:
    every: 4h
    class: AuthenticomDailyFilesImportWorker
    queue: default
    description: "This job pull data from FTP server and import it to database"

  check_alerts:
    cron: 0 2 * * *
    class: CheckAlertsWorker
    queue: default
    description: "Should check alerts"

Future of sidekiq-scheduler.

Hello, I noticed that you won't be supporting sidekiq-scheduler anymore. I understand the reasons for that but we are still using the scheduled jobs part of sidekiq-scheduler and while I could create a new gem for that purpose I would prefer (if you have no problems with that) to maintain this gem myself.
What I would do is remove the parts of that are already present in new versions of sidekiq and update the remaining code.
If you are okay with this could you put a message indicating that the gem is being maintained in https://github.com/Moove-it/sidekiq-scheduler?

I'll be waiting your response.
Thanks in advance.
Adrian.

Drop tilt version dependency

We were stuck at sidekiq-scheduler 2.0.0 due to the requirement that tilt be at version 2.0. We're currently using sass-rails 4.0.2, which requires tilt version 1.4.1. Upgrading tilt would require us to upgrade sass-rails, and upgrading sass-rails would require a good amount of effort on our part due to some major changes. As a last ditch effort, we forked the sidekiq-scheduler repo and dropped the tilt version requirement to >= 1.4.0 and pointed our gemfile to our forked repo. The gem installs fine, and, from what I can tell, functions as expected. It seems like you were only using the gem to parse erb files, and the web interface functions perfectly. Was there any reason you had tilt pegged to 2.0? If not, would you mind dropping the version requirement so that we can switch back to the official repo?

Thanks!

Fatal error in sidekiq, scheduler loop died

λ sidekiq-scheduler
2012-04-11T17:28:36Z 10635 TID-4q4 INFO: Booting sidekiq scheduler 0.2.1 with Redis at localhost:6379
2012-04-11T17:28:36Z 10635 TID-4q6 INFO: Booting sidekiq 1.0.0 with Redis at localhost:6379
2012-04-11T17:28:36Z 10635 TID-4q6 INFO: Running in jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
2012-04-11T17:28:36Z 10635 TID-4q4 ERROR: Fatal error in sidekiq, scheduler loop died2012-04-11T17:28:36Z 10635 TID-4q4 ERROR: wrong number of arguments (2 for 1)
2012-04-11T17:28:36Z 10635 TID-4q4 ERROR: /Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/sidekiq-scheduler-0.2.1/lib/sidekiq-scheduler/manager.rb:52:in find_scheduled_work' org/jruby/RubyKernel.java:1410:inloop'
/Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/sidekiq-scheduler-0.2.1/lib/sidekiq-scheduler/manager.rb:48:in find_scheduled_work' /Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/sidekiq-scheduler-0.2.1/lib/sidekiq-scheduler/manager.rb:72:inschedule'
org/jruby/RubyKernel.java:1410:in loop' /Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/sidekiq-scheduler-0.2.1/lib/sidekiq-scheduler/manager.rb:70:inschedule'
/Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/sidekiq-1.0.0/lib/sidekiq/util.rb:42:in watchdog' /Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/sidekiq-scheduler-0.2.1/lib/sidekiq-scheduler/manager.rb:66:inschedule'
/Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/sidekiq-scheduler-0.2.1/lib/sidekiq-scheduler/manager.rb:30:in start' org/jruby/RubyBasicObject.java:1698:insend'
org/jruby/RubyKernel.java:2097:in send' /Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/celluloid-0.10.0/lib/celluloid/calls.rb:98:indispatch'
/Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/celluloid-0.10.0/lib/celluloid/actor.rb:212:in handle_message' /Users/anil.wadghule/.rvm/gems/jruby-1.6.7@test_sidekiq/gems/celluloid-0.10.0/lib/celluloid/task.rb:45:ininitialize'
2012-04-11T17:28:37Z 10635 TID-4rq INFO: Starting processing, hit Ctrl-C to stop

Add or change scheduled job runtime.

Hi. It's possible add or change scheduled job runtime?

For now we use model for store scheduled jobs (created or deleted with change in other model). Scheduled job is correctly showed (or missing) in web interface after add/update/delete model.

Jobs work as expected on server restart.

Here is model:

# == Schema Information
#
# Table name: schedulers
#
#  id               :uuid             not null, primary key
#  job_code         :string           not null
#  job_class        :string           not null
#  job_arguments    :jsonb
#  cron_expression  :string           not null
#  schedulable_id   :uuid
#  schedulable_type :string
#  state            :string           not null
#  disabled         :boolean          not null
#  created_at       :datetime         not null
#  updated_at       :datetime         not null
#

class Scheduler < ActiveRecord::Base
  include Enableable
  strip_attributes
  has_paper_trail

  belongs_to :schedulable, polymorphic: true

  validates :job_code,        presence: true
  validates :job_class,       presence: true
  validates :cron_expression, presence: true

  after_create  :create_cron_job
  after_update  :update_cron_job
  after_destroy :destroy_cron_job

  before_save do
    self.state = :scheduled
  end

  def self.schedules
    schedules = {}

    where(disabled: false).each do |row|
      schedules[row.job_code] = {
        "cron"  => row.cron_expression,
        "class" => 'Monitoring::AutomaticFinalizeJob',
        "queue" => 'low_priority',
        "args"  => Array(row.job_arguments)
      }
    end

    schedules
  end

  def job_arguments
    return super.symbolize_keys if super.is_a?(Hash)

    super
  end

  def create_cron_job
    Sidekiq.set_schedule(self[:job_code], cron: self[:cron_expression], class: self[:job_class], queue: 'low_priority', args: self[:job_arguments])
    Sidekiq.reload_schedule!
  end

  def destroy_cron_job(another_job_code = nil)
    another_job_code ||= self[:job_code]

    Sidekiq.remove_schedule(another_job_code)
    Sidekiq.reload_schedule!
  end

  def update_cron_job
    destroy_cron_job(job_code_was) if job_code_changed? || self[:disabled]

    create_cron_job unless self[:disabled]
    Sidekiq.reload_schedule!
  end

  def run_job
    Sidekiq::Scheduler.enqueue_job(cron_job)
  end

  def cron_job
    Sidekiq.get_schedule(self[:job_code])
  end

  def exist?
    cron_job.present?
  end
end

Here is sidekiq_scheduler.rb initializer:

if Rails.env == 'production'
  Sidekiq.configure_server do |config|
    config.on(:startup) do
      if LOCAL_HOSTNAME == 'app2.local'
        schedules = {}

        # Load predefined schedules from YAML file.
        schedules.merge!(YAML.load_file(Rails.root.join('config', 'scheduler.yml')))

        # Load predefined schedules from database.
        schedules.merge!(Scheduler.schedules)

        # Set schedules.
        Sidekiq.schedule = schedules

        Sidekiq::Scheduler.enabled = true
        Sidekiq::Scheduler.listened_queues_only = true
        Sidekiq::Scheduler.reload_schedule!
      end
    end
  end
else
  Sidekiq::Scheduler.enabled = false
end

Error running rake tasks

My redis connection is configured using "config/initializers/sidekiq.rb", reading from rails-config:

connection = proc {
  redis_from_url(Settings.sidekiq.redis.url)
}

Sidekiq.configure_server do |config|
  config.redis = ConnectionPool.new(size: 20, &connection)
end

This worked fine until I added sidekiq-scheduler. Now I get this error:

Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)

I don't even have redis running locally.

If I rename "config/initializers/scheduler.rb" to "config/initializers/sidekiq_scheduler.rb" (which is loaded after the sidekiq initializer), it gives a different bizarre error.

Any information on load order for these guys or similar problems?

Add button for manual enqueue jobs through web ui

I currently migrate from sidetiq gem, which now looks unsupported and sometimes behaves unexpected and I concerned by missing buttons for manually starting jobs through web ui. This feature will be very helpful for development.

Is it possible to display next run time in web UI?

I see my recurring jobs schedule in the Sidekiq UI. Even though my schedule is listed, it's still not very clear to me exactly when they will be run. It would be nice to know when the next job is scheduled to run. It would help a lot with debugging.

I'm not familiar with the internals to know how to make this possible. Is it possible to display next run time in web UI?

conflict between sidekiq and sidekiq-scheduler

regarding this issue
#8

is both sidekiq and sidekiq-scheduler supposed to be using tmp/pids/sidekiq.pid?

this is what is happening in my capistrano log when i deploy
is this supposed to be happening?

  • 2013-10-14 17:05:35 executing `sidekiq:stop'
    • executing "if [ -d /app/current ] && [ -f /app/current/tmp/pids/sidekiq.pid ] && kill -0 cat /app/current/tmp/pids/sidekiq.pid> /dev/null 2>&1; then cd /app/current && bundle exec sidekiqctl stop /app/current/tmp/pids/sidekiq.pid 10 ; else echo 'Sidekiq is not running'; fi"
      • 2013-10-14 17:05:36 executing `sidekiq:start'
    • executing "cd /app/current ; nohup bundle exec sidekiq -e production -C /app/current/config/sidekiq.yml -i 0 -P /app/current/tmp/pids/sidekiq.pid >> /app/current/log/sidekiq.log 2>&1 &"
    • 2013-10-14 17:05:37 executing `sidekiq_scheduler:restart'
      then sidekiq-scheduler stops sidekiq which was just started
    • 2013-10-14 17:05:37 executing `sidekiq_scheduler:stop'
    • executing "cd /app/current && if [ -f /app/current/tmp/pids/sidekiq.pid ]; then bundle exec sidekiqctl stop /app/current/tmp/pids/sidekiq.pid 10 ; fi"
    • 2013-10-14 17:05:38 executing `sidekiq_scheduler:start'
    • executing "cd /app/current ; nohup bundle exec sidekiq-scheduler -e production -C /app/current/config/sidekiq.yml -P /app/current/tmp/pids/sidekiq.pid >> /app/current/log/sidekiq.log 2>&1 &"

JRuby 1.7.0 constantize error

jruby-1.7.0 :020 > Sidekiq::Scheduler.enqueue_from_config(Sidekiq.schedule['Store-61474574'])
NoMethodError: undefined method `constantize' for Sidekiq::Scheduler:Class

need change:

job_config['class'] = job_config['class'].constantize if job_config['class'].is_a?(String) # Sidekiq expects the class to be constantized.

Can't boot sidekiq with daemonize from init script

Hey, not sure if sidekiq-scheduler is responsible for this or sidekiq itself, so I'm going to open this issue both places.

I've written a unix init script to launch sidekiq using start-stop-daemon. When I try to start sidekiq using this script, I get this error when I pass in the option to daemonize.

Celluloid cannot be required until here, or it will break Sidekiq's daemonization
(...)/sidekiq-2.8.0/lib/sidekiq/cli.rb:127:in `load_celluloid'

This script fails:

start-stop-daemon --start --pidfile ${pidfile} \
    -N 2 --chuid ${run_as_user} --chdir ${app_dir} \
    --startas /usr/local/bin/bundle -- exec \
    sidekiq-scheduler -d -P ${pidfile} -e ${environment} -L ${stdout_log} -C ${config_file}

This script works:

start-stop-daemon --start --pidfile ${pidfile} \
    -N 2 --chuid ${run_as_user} --chdir ${app_dir} \
    --startas /usr/local/bin/bundle -- exec \
    sidekiq-scheduler -P ${pidfile} -e ${environment} -L ${stdout_log} -C ${config_file} &

You see I used a & in the second one instead of relying on sidekiq's internal daemonization (-d).

I'm wondering what we're doing wrong, any ideas?

Thanks!

Not processing jobs, not working.

As far as I can tell, this simply isn't working. Tested in development and production, the schedules load but never process. And that's after tinkering the code to remove the bugs (including the bang still).

If this is not maintained, do you think it would be better to remove completely so more people don't have to go through the pain of using (trying to use) something broken.

When schedules names are of type Symbol, they are removed from redis in the next process start

When sidekiq.yml has the following:

:schedule:
  :remove_temp_files: # This key is loaded as a Symbol
    cron: " ..." 

The schedule :remove_temp_files is stored in Redis during sidekiq startup, while during the next startup is removed from redis. In the next startup the shedule will stored in Redis.

This occurs because SidekiqScheduler::Schedule#get_all_schedules fetches a Hash of schedules from Redis, and that hash's keys are strings.

The fetch/remove/add occurs here:
https://github.com/moove-it/sidekiq-scheduler/blob/master/lib/sidekiq-scheduler/schedule.rb#L40

Schedules aren't pulled from Redis when changed

With dynamic option set to true I would expect my Sidekiq proces to regularly pull changed schedules from Redis.

Sidekiq::Scheduler.�update_schedule looks like it is supposed to do so but it's never called (except for a unit test).

Issue loading sidekiq-scheduler/web

Whatever I do, I keep getting this error:

19:35:55 web.1     | [24973] ! Unable to load application: LoadError: cannot load such file -- sidekiq-scheduler/web

My load in config/routes.rb looks like this:

require 'admin_constraint'
require 'sidekiq/web'
require 'sidekiq-scheduler/web'

BattleHack::Application.routes.draw do
  ...
  mount Sidekiq::Web => '/admin/sidekiq', constraints: AdminConstraint.new
  ...

Losts of duplicated tasks created?

we currently have 5 machines to run sidekiq with sidekiq-scheduler enabled. but the situation is every worker will start a scheduled job at time which means that there will be 4 duplicated jobs created.
how can I solve this?

Buid a new Version

The latest version available for this gem on rubygems is 0.4.1. There are bugs that completely prevent the use of this gem but are fixed in the current master (such as #26).

It looks like the VERSION file has already been updated within the repo and a gem just never got pushed.

Sidekiq Version

I'm using version 2.17.7 of sidekiq and can't use your plugin (trying to use the develop branch currently) as your spec requires ~> 2.12.0.

It looks like you are preparing for a new release, are you planning on updating the sidekiq version as well?

Thanks!

Schedule not being reloaded when starting Rails app

I'm seeing an issue where restarting the Rails app does not reload the schedule.

Following the README example, I have an initializer that loads config/schedule.yml

require 'sidekiq/scheduler'
Sidekiq.schedule = YAML.load_file(File.expand_path('../../../config/schedule.yml', __FILE__))

If the following is my schedule.yml

vagrant@precise64:/vagrant$ cat config/schedule.yml
############################################################################
# Defines the schedule of recurring Sidekiq jobs
# See https://github.com/Moove-it/sidekiq-scheduler for more information
############################################################################

# run, every minute, the job to look for delayed orders
queue_delayed_order_notifications:
  every: ["1m"]
  class: DelayedOrderNotifications
  description: "This job looks for delayed orders and triggers the appropriate notifications"

It loads fine:

vagrant@precise64:/vagrant$ bundle exec rails c
Loading development environment (Rails 4.1.2)
[1] pry(main)> Sidekiq.schedule
=> {"queue_delayed_order_notifications"=>
  {"every"=>["1m"],
   "class"=>"DelayedOrderNotifications",
   "description"=>"This job looks for delayed orders and triggers the appropriate notifications"}}

However, if I change the schedule - so changing from 1m to 1h:

vagrant@precise64:/vagrant$ cat config/schedule.yml
############################################################################
# Defines the schedule of recurring Sidekiq jobs
# See https://github.com/Moove-it/sidekiq-scheduler for more information
############################################################################

# run, every minute, the job to look for delayed orders
queue_delayed_order_notifications:
  every: ["1h"]
  class: DelayedOrderNotifications
  description: "This job looks for delayed orders and triggers the appropriate notifications"

Then I reload Rails:

vagrant@precise64:/vagrant$ bundle exec rails c
Loading development environment (Rails 4.1.2)
[1] pry(main)> Sidekiq.schedule
=> {"queue_delayed_order_notifications"=>
  {"every"=>["1m"],
   "class"=>"DelayedOrderNotifications",
   "description"=>"This job looks for delayed orders and triggers the appropriate notifications"}}

The schedule has not changed. It's still 1m in Sidekiq, even though I've completely reloaded the app.

In fact, in my Vagrant development environment, the only thing that I found to reload the schedule is actually to reboot the VM.

Is this expected? I've used Resque scheduler before, so I'm expecting behavior similar to that - with Resque scheduler, the schedule was loaded fresh every time the Rails app was restarted.

Not seeing scheduled tasks in web

Hey, just tried the new gem release. This is my sidekiq.yml:

---
:timeout: 8
:queues:
  - priority_emails
  - emails
  - releases
  - default

:schedule:
  process_emails_due:
    cron: "* * * * *"
    queue: emails
    class: "EmailsDueWorker"

  process_releases_due:
    cron: "* * * * *"
    queue: releases
    class: "ReleasesDueWorker"

  process_releases_expire_on_start:
    cron: "* * * * *"
    queue: releases
    class: "ReleasesExpireOnStartWorker"

The tasks are scheduled but somehow I'm not seeing them in the dashboard

Future of sidekiq-scheduler.

Hello, I noticed that you won't be supporting sidekiq-scheduler anymore. I understand the reasons for that but we are still using the scheduled jobs part of sidekiq-scheduler and while I could create a new gem for that purpose I would prefer (if you have no problems with that) to maintain this gem myself.
What I would do is remove the parts of that are already present in new versions of sidekiq and update the remaining code.
If you are okay with this could you put a message indicating that the gem is being maintained in https://github.com/Moove-it/sidekiq-scheduler?

I'll be waiting your response.
Thanks in advance.
Adrian.

Documentation - Resque workers?

In the main readme:

The schedule is a list of Resque worker classes with arguments and a schedule frequency (in crontab syntax). The schedule is just a hash, but is most likely stored in a YAML like so:

I'm assuming that should refer to Sidekiq jobs? (I'm brand new to sidkiq, just doing early investigations, so I don't really know)

Cron job doesn't run

Hi,

I'm trying to run a job with the cron: "0 0 19 * * *" but it doesn't ever run.

I'f I click the enqueue button on the web interface it runs my job though.

Any ideas where I am going wrong?

Job is scheduled on each queue.

When I schedule a job it is processed on each queue I have.

For example the job will be scheduled and run three times with the following code. Even though it should only run on the worker queue it runs on a worker queue on both the reports and payment sidekiqs

Scheduler:

:schedule:
  DailyCheckWorker:
    cron: "0 20 00 * * *"
    class: DailyCheckWorker
    queue: worker
    description: "abcdef"

Procfile:

web: bundle exec puma -C config/puma.rb
reports: bundle exec sidekiq -q reports
worker: bundle exec sidekiq -q worker
payment: bundle exec sidekiq -q payment

Sidekiq Web

I'm running sidekiq-scheduler with a default of 25 workers. I've noticed that whenever I restart sidekiq-scheduler, the number of workers displayed on the web increments by 25 (ie, restarting 3 times makes sidekiq web says 75 workers).

The log file reports that it shut down 25 workers, so I'm thinking it is a red herring, or perhaps I'm misinterpreting what that number means. I wanted to post this in sidekiq-scheduler before I ask over at sidekiq proper.

This very well may be a non-issue.

Thanks.

Multiple schedules are loaded for multiple workers

We have an environment where we have multiple worker processes and each of this process loads up the scheudler
ie we have:
scheduler: bundle exec sidekiq -c 5 -q scheduler -q default
worker: bundle exec sidekiq -c 5 -q default

So we end up with duplicate schedules , how can we avoid it?

Jobs run 2x as often

We have an issue with Sidekiq 4 and Sidekiq-Scheduler where our jobs are running 2x as often as they should.

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.