Skip to content

Instantly share code, notes, and snippets.

@ivorpad
Created August 31, 2022 11:05
Show Gist options
  • Save ivorpad/d552a22e3b3438c18c268aef3550c157 to your computer and use it in GitHub Desktop.
Save ivorpad/d552a22e3b3438c18c268aef3550c157 to your computer and use it in GitHub Desktop.
Start Job in sidekiq-scheduler dynamically
Sidekiq.schedule = {"hello_world"=>{"dynamic"=>true, "cron"=>"* * * * * *", "class"=>"HelloJob", "enabled"=>false}}
Sidekiq::Scheduler.enabled = true
Sidekiq::Scheduler.reload_schedule!
# or
SidekiqScheduler::RedisManager.get_job_state("hello_world") # "{\"enabled\":false}"
state = {"enabled" => true}
SidekiqScheduler::RedisManager.set_job_state("hello_world", state)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment