Skip to content

Commit

Permalink
[ADD] Readme for importing jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejbartas committed Aug 25, 2013
1 parent cdf28d4 commit 9e7e077
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,71 @@ unless job.save
end
```

Load more jobs from hash:
```ruby

hash = {
'name_of_job' => {
'class' => 'MyClass',
'cron' => '1 * * * *',
'args' => '(OPTIONAL) [Array or Hash]'
},
'My super iber cool job' => {
'class' => 'SecondClass',
'cron' => '*/5 * * * *'
}
}

Sidekiq::Cron::Job.load_from_hash hash
```

Load more jobs from array:
```ruby
array = [
{
'name' => 'name_of_job',
'class' => 'MyClass',
'cron' => '1 * * * *',
'args' => '(OPTIONAL) [Array or Hash]'
},
{
'name' => 'Cool Job for Second Class',
'class' => 'SecondClass',
'cron' => '*/5 * * * *'
}
]

Sidekiq::Cron::Job.load_from_array array
```

or from YML (same notation as Resque-scheduler)
```yaml
#config/shedule.yml

my_first_job:
cron: "*/5 * * * *"
class: "HardWorker"
queue: hard_worker

second_job:
cron: "*/30 * * * *"
class: "HardWorker"
queue: hard_worker_long
args:
hard: "stuff"
```

```ruby
#initializers/sidekiq.rb
schedule_file = "config/schedule.yml"

if File.exists?(schedule_file)
Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
end
```



#### Finding jobs
```ruby
#return array of all jobs
Expand Down

0 comments on commit 9e7e077

Please sign in to comment.