recurrent 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +1 -1
- data/bin/recurrent +2 -3
- data/lib/recurrent/configuration.rb +1 -1
- data/lib/recurrent/task.rb +5 -2
- data/lib/recurrent/version.rb +1 -1
- data/lib/recurrent/worker.rb +0 -2
- data/spec/task_spec.rb +6 -0
- data/spec/worker_spec.rb +1 -1
- metadata +136 -155
- data/.rvmrc +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a45002b50684d1431f2e070a0166a8e77fee134c
|
4
|
+
data.tar.gz: 35c41dcb7ddb6a24c60dfb04f89cc17de5c0125d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c9f76d32f033df82b5db2cc0e8b7b5b6df9199e4e22fb50075b0e661569aeddb46e262b95298b01aeaca327692628ea0259634b5e749cd377c831ebca3cf2f8b
|
7
|
+
data.tar.gz: a90b47b2381c800d769c88a2f41ee2d45ab6d48d3974911b976726c93173cff1ad5217008435b25f88c73d363129027d2297004965b433341f4740425e9c9d78
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/bin/recurrent
CHANGED
@@ -9,8 +9,7 @@ opts = Trollop::options do
|
|
9
9
|
opt :system, "Command to send to the command line", :type => :string
|
10
10
|
opt :name, "Name of the task", :default => 'command_line'
|
11
11
|
opt :maximum_concurrent_tasks, "Maximum number of concurrent tasks to run", :type => :integer
|
12
|
-
opt :
|
13
|
-
opt :locker_pool_size, "Size of locker database connection pool (should be >= maximum_concurrent_tasks)", :type => :integer
|
12
|
+
opt :process_name, "Name of the worker process", :type => :string
|
14
13
|
end
|
15
14
|
|
16
15
|
begin
|
@@ -18,5 +17,5 @@ begin
|
|
18
17
|
rescue LoadError
|
19
18
|
require 'recurrent'
|
20
19
|
end
|
21
|
-
$0 = "recurrent:worker:started-#{Time.now.to_s(:logging)}"
|
20
|
+
$0 = opts[:process_name] || "recurrent:worker:started-#{Time.now.to_s(:logging)}"
|
22
21
|
Recurrent::Worker.new(opts).start
|
@@ -3,7 +3,7 @@ module Recurrent
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
-
attr_accessor :logging, :wait_for_running_tasks_on_exit_for, :maximum_concurrent_tasks
|
6
|
+
attr_accessor :logging, :wait_for_running_tasks_on_exit_for, :maximum_concurrent_tasks
|
7
7
|
|
8
8
|
def self.block_accessor(*fields)
|
9
9
|
fields.each do |field|
|
data/lib/recurrent/task.rb
CHANGED
@@ -17,12 +17,15 @@ module Recurrent
|
|
17
17
|
|
18
18
|
def execute(execution_time)
|
19
19
|
return handle_still_running(execution_time) if running?
|
20
|
-
return if Configuration.maximum_concurrent_tasks.present? && (scheduler.executing_tasks >= Configuration.maximum_concurrent_tasks)
|
21
20
|
@thread = Thread.new do
|
22
21
|
Thread.current["execution_time"] = execution_time
|
23
22
|
scheduler && scheduler.increment_executing_tasks
|
24
23
|
begin
|
25
|
-
|
24
|
+
if Configuration.maximum_concurrent_tasks.present?
|
25
|
+
call_action(execution_time) unless (scheduler.executing_tasks > Configuration.maximum_concurrent_tasks)
|
26
|
+
else
|
27
|
+
call_action(execution_time)
|
28
|
+
end
|
26
29
|
rescue => e
|
27
30
|
logger.warn("#{name} - #{e.message}")
|
28
31
|
logger.warn(e.backtrace)
|
data/lib/recurrent/version.rb
CHANGED
data/lib/recurrent/worker.rb
CHANGED
@@ -5,8 +5,6 @@ module Recurrent
|
|
5
5
|
|
6
6
|
def initialize(options={})
|
7
7
|
Configuration.maximum_concurrent_tasks = options[:maximum_concurrent_tasks]
|
8
|
-
Configuration.pool_size = options[:pool_size]
|
9
|
-
Configuration.locker_pool_size = options[:locker_pool_size]
|
10
8
|
Configuration.setup.call if Configuration.setup
|
11
9
|
file = options[:file]
|
12
10
|
@scheduler = Scheduler.new(file)
|
data/spec/task_spec.rb
CHANGED
@@ -37,6 +37,7 @@ module Recurrent
|
|
37
37
|
|
38
38
|
it "sets its execution_time" do
|
39
39
|
@task.execute(@current_time)
|
40
|
+
@task.thread.join
|
40
41
|
@task.thread['execution_time'].should == @current_time
|
41
42
|
end
|
42
43
|
|
@@ -51,6 +52,7 @@ module Recurrent
|
|
51
52
|
it "calls the action with a nil argument" do
|
52
53
|
@task.action.should_receive(:call)
|
53
54
|
@task.execute(@current_time)
|
55
|
+
@task.thread.join
|
54
56
|
end
|
55
57
|
end
|
56
58
|
|
@@ -62,6 +64,7 @@ module Recurrent
|
|
62
64
|
it "loads the task return value and calls the action with it as an argument" do
|
63
65
|
@task.action.should_receive(:call).with("testing")
|
64
66
|
@task.execute(@current_time)
|
67
|
+
@task.thread.join
|
65
68
|
end
|
66
69
|
|
67
70
|
after :each do
|
@@ -111,6 +114,7 @@ module Recurrent
|
|
111
114
|
context "When no method for handling a still running task is configured" do
|
112
115
|
it "just logs that the task is still running" do
|
113
116
|
@task.logger.should_receive(:info).with("handle_still_running_test: Execution from #{@executing_task_time.to_s(:seconds)} still running, aborting this execution.")
|
117
|
+
@task.thread.join
|
114
118
|
@task.handle_still_running(@current_time)
|
115
119
|
end
|
116
120
|
end
|
@@ -168,6 +172,7 @@ module Recurrent
|
|
168
172
|
@task = Task.new :name => 'save_results_test', :logger => Logger.new('some identifier')
|
169
173
|
@current_time = Time.now
|
170
174
|
@task.thread = Thread.new { Thread.current["execution_time"] = @current_time }
|
175
|
+
@task.thread.join
|
171
176
|
end
|
172
177
|
|
173
178
|
it "calls the method and logs that the value was saved" do
|
@@ -201,6 +206,7 @@ module Recurrent
|
|
201
206
|
t = Task.new
|
202
207
|
t.thread = Thread.new { sleep 1 }
|
203
208
|
t.thread.kill
|
209
|
+
sleep 0.1
|
204
210
|
t.running?.should be_false
|
205
211
|
end
|
206
212
|
end
|
data/spec/worker_spec.rb
CHANGED
@@ -36,7 +36,7 @@ module Recurrent
|
|
36
36
|
waiting_thread = Thread.new { Worker.new.wait_until(Time.local(2011, 7, 26, 11, 40, 00)) }
|
37
37
|
waiting_thread.alive?.should be_true
|
38
38
|
Timecop.travel(Time.local(2011, 7, 26, 11, 40, 00))
|
39
|
-
sleep(0.
|
39
|
+
sleep(0.51)
|
40
40
|
waiting_thread.alive?.should be_false
|
41
41
|
Timecop.return
|
42
42
|
end
|
metadata
CHANGED
@@ -1,164 +1,153 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: recurrent
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
- 0
|
10
|
-
version: 0.4.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Adam Kittelson
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: ice_cube
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
- - "="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 23
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 6
|
32
|
-
- 8
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
33
19
|
version: 0.6.8
|
34
20
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: activesupport
|
38
21
|
prerelease: false
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
48
34
|
type: :runtime
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: i18n
|
52
35
|
prerelease: false
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: i18n
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
62
48
|
type: :runtime
|
63
|
-
version_requirements: *id003
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: trollop
|
66
49
|
prerelease: false
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: trollop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
76
62
|
type: :runtime
|
77
|
-
version_requirements: *id004
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: rspec
|
80
63
|
prerelease: false
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
90
76
|
type: :development
|
91
|
-
version_requirements: *id005
|
92
|
-
- !ruby/object:Gem::Dependency
|
93
|
-
name: autotest
|
94
77
|
prerelease: false
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: autotest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
104
90
|
type: :development
|
105
|
-
version_requirements: *id006
|
106
|
-
- !ruby/object:Gem::Dependency
|
107
|
-
name: timecop
|
108
91
|
prerelease: false
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: timecop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
118
104
|
type: :development
|
119
|
-
version_requirements: *id007
|
120
|
-
- !ruby/object:Gem::Dependency
|
121
|
-
name: pry
|
122
105
|
prerelease: false
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
132
118
|
type: :development
|
133
|
-
version_requirements: *id008
|
134
|
-
- !ruby/object:Gem::Dependency
|
135
|
-
name: pry-doc
|
136
119
|
prerelease: false
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-doc
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
146
132
|
type: :development
|
147
|
-
|
148
|
-
|
149
|
-
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Task scheduler that doesn't need to bootstrap your Rails environment
|
140
|
+
every time it executes a task the way running a rake task via cron does.
|
141
|
+
email:
|
150
142
|
- adam@zencoder.com
|
151
|
-
executables:
|
143
|
+
executables:
|
152
144
|
- recurrent
|
153
145
|
extensions: []
|
154
|
-
|
155
146
|
extra_rdoc_files: []
|
156
|
-
|
157
|
-
files:
|
147
|
+
files:
|
158
148
|
- .autotest
|
159
149
|
- .gitignore
|
160
150
|
- .rspec
|
161
|
-
- .rvmrc
|
162
151
|
- .zenflow
|
163
152
|
- CHANGELOG.md
|
164
153
|
- Gemfile
|
@@ -185,41 +174,33 @@ files:
|
|
185
174
|
- spec/worker_spec.rb
|
186
175
|
homepage: http://github.com/zencoder/recurrent
|
187
176
|
licenses: []
|
188
|
-
|
177
|
+
metadata: {}
|
189
178
|
post_install_message:
|
190
179
|
rdoc_options: []
|
191
|
-
|
192
|
-
require_paths:
|
180
|
+
require_paths:
|
193
181
|
- - lib
|
194
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
none: false
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
hash: 3
|
209
|
-
segments:
|
210
|
-
- 0
|
211
|
-
version: "0"
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - '>='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
212
192
|
requirements: []
|
213
|
-
|
214
193
|
rubyforge_project:
|
215
|
-
rubygems_version:
|
194
|
+
rubygems_version: 2.0.3
|
216
195
|
signing_key:
|
217
|
-
specification_version:
|
218
|
-
summary: Task scheduler that doesn't need to bootstrap your Rails environment every
|
219
|
-
|
196
|
+
specification_version: 4
|
197
|
+
summary: Task scheduler that doesn't need to bootstrap your Rails environment every
|
198
|
+
time it executes a task the way running a rake task via cron does.
|
199
|
+
test_files:
|
220
200
|
- spec/logger_spec.rb
|
221
201
|
- spec/scheduler_spec.rb
|
222
202
|
- spec/spec_helper.rb
|
223
203
|
- spec/task_collection_spec.rb
|
224
204
|
- spec/task_spec.rb
|
225
205
|
- spec/worker_spec.rb
|
206
|
+
has_rdoc:
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm 1.8.7@recurrent
|