delayed_job 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/benchmarks.rb +2 -0
- data/contrib/delayed_job_multiple.monitrc +23 -0
- data/delayed_job.gemspec +4 -2
- data/init.rb +1 -5
- data/lib/delayed/command.rb +28 -11
- data/rails/init.rb +5 -0
- data/spec/setup/mongo_mapper.rb +4 -2
- data/spec/spec_helper.rb +1 -0
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.3
|
data/benchmarks.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# an example Monit configuration file for delayed_job running multiple processes
|
2
|
+
#
|
3
|
+
# To use:
|
4
|
+
# 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc
|
5
|
+
# 2. replace {app_name} as appropriate
|
6
|
+
# 3. add this to your /etc/monit/monitrc
|
7
|
+
#
|
8
|
+
# include /var/www/apps/{app_name}/shared/delayed_job.monitrc
|
9
|
+
|
10
|
+
check process delayed_job_0
|
11
|
+
with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.0.pid
|
12
|
+
start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start -i 0"
|
13
|
+
stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop -i 0"
|
14
|
+
|
15
|
+
check process delayed_job_1
|
16
|
+
with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.1.pid
|
17
|
+
start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start -i 1"
|
18
|
+
stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop -i 1"
|
19
|
+
|
20
|
+
check process delayed_job_2
|
21
|
+
with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.2.pid
|
22
|
+
start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start -i 2"
|
23
|
+
stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop -i 2"
|
data/delayed_job.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{delayed_job}
|
8
|
-
s.version = "2.0.
|
8
|
+
s.version = "2.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brandon Keepers", "Tobias L\303\274tke"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-16}
|
13
13
|
s.description = %q{Delayed_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. It is a direct extraction from Shopify where the job table is responsible for a multitude of core tasks.
|
14
14
|
|
15
15
|
This gem is collectiveidea's fork (http://github.com/collectiveidea/delayed_job).}
|
@@ -25,6 +25,7 @@ This gem is collectiveidea's fork (http://github.com/collectiveidea/delayed_job)
|
|
25
25
|
"VERSION",
|
26
26
|
"benchmarks.rb",
|
27
27
|
"contrib/delayed_job.monitrc",
|
28
|
+
"contrib/delayed_job_multiple.monitrc",
|
28
29
|
"delayed_job.gemspec",
|
29
30
|
"generators/delayed_job/delayed_job_generator.rb",
|
30
31
|
"generators/delayed_job/templates/migration.rb",
|
@@ -42,6 +43,7 @@ This gem is collectiveidea's fork (http://github.com/collectiveidea/delayed_job)
|
|
42
43
|
"lib/delayed/tasks.rb",
|
43
44
|
"lib/delayed/worker.rb",
|
44
45
|
"lib/delayed_job.rb",
|
46
|
+
"rails/init.rb",
|
45
47
|
"recipes/delayed_job.rb",
|
46
48
|
"spec/backend/active_record_job_spec.rb",
|
47
49
|
"spec/backend/data_mapper_job_spec.rb",
|
data/init.rb
CHANGED
data/lib/delayed/command.rb
CHANGED
@@ -8,7 +8,10 @@ module Delayed
|
|
8
8
|
|
9
9
|
def initialize(args)
|
10
10
|
@files_to_reopen = []
|
11
|
-
@options = {
|
11
|
+
@options = {
|
12
|
+
:quiet => true,
|
13
|
+
:pid_dir => "#{RAILS_ROOT}/tmp/pids"
|
14
|
+
}
|
12
15
|
|
13
16
|
@worker_count = 1
|
14
17
|
|
@@ -31,6 +34,12 @@ module Delayed
|
|
31
34
|
opts.on('-n', '--number_of_workers=workers', "Number of unique workers to spawn") do |worker_count|
|
32
35
|
@worker_count = worker_count.to_i rescue 1
|
33
36
|
end
|
37
|
+
opts.on('--pid-dir=DIR', 'Specifies an alternate directory in which to store the process ids.') do |dir|
|
38
|
+
@options[:pid_dir] = dir
|
39
|
+
end
|
40
|
+
opts.on('-i', '--identifier=n', 'A numeric identifier for the worker.') do |n|
|
41
|
+
@options[:identifier] = n
|
42
|
+
end
|
34
43
|
end
|
35
44
|
@args = opts.parse!(args)
|
36
45
|
end
|
@@ -42,33 +51,41 @@ module Delayed
|
|
42
51
|
@files_to_reopen << file unless file.closed?
|
43
52
|
end
|
44
53
|
|
45
|
-
dir =
|
54
|
+
dir = @options[:pid_dir]
|
46
55
|
Dir.mkdir(dir) unless File.exists?(dir)
|
47
56
|
|
48
|
-
worker_count
|
49
|
-
|
50
|
-
|
51
|
-
|
57
|
+
if @worker_count > 1 && @options[:identifier]
|
58
|
+
raise ArgumentError, 'Cannot specify both --number-of-workers and --identifier'
|
59
|
+
elsif @worker_count == 1 && @options[:identifier]
|
60
|
+
process_name = "delayed_job.#{@options[:identifier]}"
|
61
|
+
run_process(process_name, dir)
|
62
|
+
else
|
63
|
+
worker_count.times do |worker_index|
|
64
|
+
process_name = worker_count == 1 ? "delayed_job" : "delayed_job.#{worker_index}"
|
65
|
+
run_process(process_name, dir)
|
52
66
|
end
|
53
67
|
end
|
54
68
|
end
|
55
69
|
|
70
|
+
def run_process(process_name, dir)
|
71
|
+
Daemons.run_proc(process_name, :dir => dir, :dir_mode => :normal, :ARGV => @args) do |*args|
|
72
|
+
run process_name
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
56
76
|
def run(worker_name = nil)
|
57
77
|
Dir.chdir(RAILS_ROOT)
|
58
78
|
|
59
79
|
# Re-open file handles
|
60
80
|
@files_to_reopen.each do |file|
|
61
81
|
begin
|
62
|
-
file.reopen
|
82
|
+
file.reopen file.path
|
63
83
|
file.sync = true
|
64
84
|
rescue ::Exception
|
65
85
|
end
|
66
86
|
end
|
67
87
|
|
68
|
-
Delayed::Worker.logger =
|
69
|
-
if Delayed::Worker.logger.respond_to? :auto_flushing=
|
70
|
-
Delayed::Worker.logger.auto_flushing = true
|
71
|
-
end
|
88
|
+
Delayed::Worker.logger = Logger.new(File.join(RAILS_ROOT, 'log', 'delayed_job.log'))
|
72
89
|
Delayed::Worker.backend.after_fork
|
73
90
|
|
74
91
|
worker = Delayed::Worker.new(@options)
|
data/rails/init.rb
ADDED
data/spec/setup/mongo_mapper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'mongo_mapper'
|
2
2
|
|
3
|
-
MongoMapper.
|
4
|
-
|
3
|
+
MongoMapper.config = {
|
4
|
+
RAILS_ENV => {'database' => 'delayed_job'}
|
5
|
+
}
|
6
|
+
MongoMapper.connect RAILS_ENV
|
5
7
|
|
6
8
|
unless defined?(Story)
|
7
9
|
class Story
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 2.0.
|
8
|
+
- 3
|
9
|
+
version: 2.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brandon Keepers
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-04-
|
18
|
+
date: 2010-04-16 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- VERSION
|
158
158
|
- benchmarks.rb
|
159
159
|
- contrib/delayed_job.monitrc
|
160
|
+
- contrib/delayed_job_multiple.monitrc
|
160
161
|
- delayed_job.gemspec
|
161
162
|
- generators/delayed_job/delayed_job_generator.rb
|
162
163
|
- generators/delayed_job/templates/migration.rb
|
@@ -174,6 +175,7 @@ files:
|
|
174
175
|
- lib/delayed/tasks.rb
|
175
176
|
- lib/delayed/worker.rb
|
176
177
|
- lib/delayed_job.rb
|
178
|
+
- rails/init.rb
|
177
179
|
- recipes/delayed_job.rb
|
178
180
|
- spec/backend/active_record_job_spec.rb
|
179
181
|
- spec/backend/data_mapper_job_spec.rb
|