que-scheduler 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -30
- data/lib/que/scheduler/schedule_parser.rb +1 -1
- data/lib/que/scheduler/scheduler_job.rb +1 -1
- data/lib/que/scheduler/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8bac5ee368ed1c96b3564c96c4e3622b9ab2277
|
4
|
+
data.tar.gz: ddef04872cbf3640dcb498c80b59eb3e6093e766
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f0aa8fde4d885e5f4cd2dc12798ccf304069e7f30775242ee4c70e3f16feb649f0a36e32be5146033bc66477605717da193ae3335217e292492908f3fc7b68d
|
7
|
+
data.tar.gz: ea10b8a5de1a8008ce79c1ce1da40decf618b9f8e2ec13f0379b93c54ac7d95e1ae23df2095fbed1fd44bad7f357304cb3664cfef7749adc3add9f5dc5bf57d1
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ que-scheduler
|
|
2
2
|
================
|
3
3
|
|
4
4
|
[![Build Status](https://travis-ci.org/resque/que-scheduler.svg?branch=master)](https://travis-ci.org/hlascelles/que-scheduler)
|
5
|
-
[![Code Climate](https://codeclimate.com/
|
5
|
+
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/710d2fc5202f95d76e8a/maintainability)](https://codeclimate.com/github/hlascelles/que-scheduler/maintainability)
|
6
6
|
|
7
7
|
### Description
|
8
8
|
|
@@ -12,28 +12,21 @@ needs to be run, enqueueing those jobs, then enqueueing itself to check again la
|
|
12
12
|
|
13
13
|
### Installation
|
14
14
|
|
15
|
-
To install, add the gem to your Gemfile:
|
15
|
+
1. To install, add the gem to your Gemfile:
|
16
|
+
```ruby
|
17
|
+
gem 'que-scheduler'
|
18
|
+
```
|
19
|
+
1. Specify a schedule config in a yml file (see below). The default location that que-scheduler will
|
20
|
+
look for it is `config/que_schedule.yml`. They are essentially the same as resque-scheduler config
|
21
|
+
files, but with additional features.
|
16
22
|
|
17
|
-
|
18
|
-
gem 'que-scheduler'
|
19
|
-
```
|
20
|
-
|
21
|
-
You will need to specify a schedule config (see below). The default location that que-scheduler will
|
22
|
-
look for it is `config/que_schedule.yml`
|
23
|
-
|
24
|
-
Finally, add a migration to start the job scheduler.
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
Que::Scheduler::SchedulerJob.enqueue
|
28
|
-
```
|
29
|
-
|
30
|
-
### Environment Variables
|
31
|
-
|
32
|
-
You can configure some aspects of the gem with environment variables.
|
33
|
-
|
34
|
-
* `QUE_SCHEDULER_CONFIG_LOCATION` - The location of the schedule configuration (default config/que_schedule.yml)
|
23
|
+
1. Add a migration to start the job scheduler.
|
35
24
|
|
36
|
-
|
25
|
+
```ruby
|
26
|
+
Que::Scheduler::SchedulerJob.enqueue
|
27
|
+
```
|
28
|
+
|
29
|
+
### Schedule configuration
|
37
30
|
|
38
31
|
The schedule file is a list of que job classes with arguments and a schedule frequency (in crontab
|
39
32
|
syntax). The format is a superset of the resque-scheduler config format, so it they can be used
|
@@ -55,7 +48,7 @@ queue_documents_for_indexing:
|
|
55
48
|
# If you want to have a different job name and class name, provide the 'class' option
|
56
49
|
class: "QueueDocuments"
|
57
50
|
queue: high
|
58
|
-
args:
|
51
|
+
args: ['reports', 'expenses']
|
59
52
|
|
60
53
|
clear_leaderboards_contributors:
|
61
54
|
cron: "30 6 * * 1"
|
@@ -66,24 +59,33 @@ clear_leaderboards_contributors:
|
|
66
59
|
DailyBatchReport:
|
67
60
|
cron: "0 3 * * *"
|
68
61
|
# This job will be run every day, and if workers are offline for several days, then the backlog
|
69
|
-
# will all be scheduled when they are restored, each with that events timestamp.
|
62
|
+
# will all be scheduled when they are restored, each with that events timestamp as the first arg.
|
70
63
|
unmissable: true
|
71
64
|
```
|
72
65
|
|
66
|
+
### Environment Variables
|
67
|
+
|
68
|
+
You can configure some aspects of the gem with environment variables.
|
69
|
+
|
70
|
+
* `QUE_SCHEDULER_CONFIG_LOCATION` - The location of the schedule configuration (default `config/que_schedule.yml`)
|
71
|
+
|
73
72
|
### Redundancy and Fail-Over
|
74
73
|
|
75
74
|
Because of the way que-scheduler works, it requires no additional processes. It is, itself, a Que job.
|
76
|
-
As long as there are Que workers functioning, then jobs will continue to be scheduled correctly.
|
75
|
+
As long as there are Que workers functioning, then jobs will continue to be scheduled correctly. There
|
76
|
+
are no HA concerns to worry about and no namespace collisions between different databases.
|
77
|
+
|
78
|
+
Additionally, like Que, when your database is backed up, your scheduling state is stored too.
|
77
79
|
|
78
80
|
### How it works
|
79
81
|
|
80
|
-
que-scheduler is a job that reads a config file,
|
81
|
-
|
82
|
+
que-scheduler is a job that reads a config file, enqueues any jobs it determines that need to be run,
|
83
|
+
then reschedules itself. The flow is as follows:
|
82
84
|
|
83
|
-
1. The job for the very first time.
|
84
|
-
1. que-scheduler loads the config file
|
85
|
-
1. Some time later it runs again. It knows what jobs it should be monitoring, and notices that some have are due. It enqueues those jobs and itself.
|
86
|
-
1. After a deploy that changes the config,
|
85
|
+
1. The que-scheduler job runs for the very first time.
|
86
|
+
1. que-scheduler loads the schedule config file. It will not schedule any other jobs, except itself, as it has never run before.
|
87
|
+
1. Some time later it runs again. It knows what jobs it should be monitoring, and notices that some have are due. It enqueues those jobs and then itself. Repeat.
|
88
|
+
1. After a deploy that changes the config, the job notices any new jobs to schedule, and knows which ones to forget. It does not need to be re-enqueued or restarted.
|
87
89
|
|
88
90
|
### Thanks
|
89
91
|
|
@@ -55,7 +55,7 @@ module Que
|
|
55
55
|
def next_run_time(cron, from, to)
|
56
56
|
fugit_cron = Fugit::Cron.parse(cron)
|
57
57
|
next_time = fugit_cron.next_time(from)
|
58
|
-
next_run = next_time.to_local_time
|
58
|
+
next_run = next_time.to_local_time.in_time_zone(next_time.zone)
|
59
59
|
next_run <= to ? next_run : nil
|
60
60
|
end
|
61
61
|
end
|
@@ -10,7 +10,7 @@ module Que
|
|
10
10
|
|
11
11
|
def run(last_time = nil, known_jobs = [])
|
12
12
|
::ActiveRecord::Base.transaction do
|
13
|
-
last_time = last_time.nil? ? Time.now : Time.parse(last_time)
|
13
|
+
last_time = last_time.nil? ? Time.now : Time.zone.parse(last_time)
|
14
14
|
as_time = Time.now
|
15
15
|
|
16
16
|
result =
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: que-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Lascelles
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0.7'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: zonebie
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.6'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.6'
|
167
181
|
description: A lightweight cron scheduler for the async job worker Que
|
168
182
|
email:
|
169
183
|
- harry@harrylascelles.com
|