canvas-jobs 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayed/pool.rb +6 -21
- data/lib/delayed/settings.rb +34 -0
- data/lib/delayed/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc057ee6906ea7379cfb792230dafc66f213acad
|
4
|
+
data.tar.gz: 77fe7aa819367091e923f105c9c06f914df3468e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9db129cd415d8e054d17aee72e40a7a15cff7b79b81919ee72af8a1c681b09273f23076aa451891283533fa3fa1f6be0cb947a28dd57d000374386aef55a292
|
7
|
+
data.tar.gz: 3959cbd432ec566d779f88a00dd7c2e777f8a3235b2ae0e7ee3f28a99fe2337590d0be8d2978b6cecd8a7e2abd645bd3a6f56d0fa94de872664bc0d16c78cd7a
|
data/lib/delayed/pool.rb
CHANGED
@@ -15,8 +15,8 @@ class Pool
|
|
15
15
|
@workers = {}
|
16
16
|
@config = { :workers => [] }
|
17
17
|
@options = {
|
18
|
-
:config_file =>
|
19
|
-
:pid_folder => expand_rails_path("tmp/pids"),
|
18
|
+
:config_file => Settings.default_worker_config_name,
|
19
|
+
:pid_folder => Settings.expand_rails_path("tmp/pids"),
|
20
20
|
:tail_logs => true, # only in FG mode
|
21
21
|
}
|
22
22
|
end
|
@@ -120,7 +120,7 @@ class Pool
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def load_rails
|
123
|
-
require(expand_rails_path("config/environment.rb"))
|
123
|
+
require(Settings.expand_rails_path("config/environment.rb"))
|
124
124
|
Dir.chdir(Rails.root)
|
125
125
|
end
|
126
126
|
|
@@ -248,7 +248,7 @@ class Pool
|
|
248
248
|
# it somewhere useful
|
249
249
|
last_ditch_logfile = self.last_ditch_logfile || "log/delayed_job.log"
|
250
250
|
if last_ditch_logfile[0] != '|'
|
251
|
-
last_ditch_logfile = expand_rails_path(last_ditch_logfile)
|
251
|
+
last_ditch_logfile = Settings.expand_rails_path(last_ditch_logfile)
|
252
252
|
end
|
253
253
|
STDIN.reopen("/dev/null")
|
254
254
|
STDOUT.reopen(open(last_ditch_logfile, 'a'))
|
@@ -312,26 +312,11 @@ class Pool
|
|
312
312
|
end
|
313
313
|
|
314
314
|
def read_config(config_filename)
|
315
|
-
config =
|
316
|
-
env = defined?(RAILS_ENV) ? RAILS_ENV : ENV['RAILS_ENV'] || 'development'
|
317
|
-
@config = config[env] || config['default']
|
318
|
-
# Backwards compatibility from when the config was just an array of queues
|
319
|
-
@config = { :workers => @config } if @config.is_a?(Array)
|
320
|
-
unless @config && @config.is_a?(Hash)
|
321
|
-
raise ArgumentError,
|
322
|
-
"Invalid config file #{config_filename}"
|
323
|
-
end
|
315
|
+
@config = Settings.worker_config(config_filename)
|
324
316
|
end
|
325
317
|
|
326
318
|
def apply_config
|
327
|
-
@config
|
328
|
-
Settings::SETTINGS.each do |setting|
|
329
|
-
Settings.send("#{setting}=", @config[setting.to_s]) if @config.key?(setting.to_s)
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
def expand_rails_path(path)
|
334
|
-
File.expand_path("../#{path}", ENV['BUNDLE_GEMFILE'])
|
319
|
+
Settings.apply_worker_config!(@config)
|
335
320
|
end
|
336
321
|
|
337
322
|
end
|
data/lib/delayed/settings.rb
CHANGED
@@ -28,5 +28,39 @@ module Delayed
|
|
28
28
|
|
29
29
|
self.num_strands = ->(strand_name){ nil }
|
30
30
|
self.default_job_options = ->{ Hash.new }
|
31
|
+
|
32
|
+
def self.worker_config(config_filename = nil)
|
33
|
+
config_filename ||= default_worker_config_name
|
34
|
+
config = YAML.load(ERB.new(File.read(config_filename)).result)
|
35
|
+
env = defined?(RAILS_ENV) ? RAILS_ENV : ENV['RAILS_ENV'] || 'development'
|
36
|
+
config = config[env] || config['default']
|
37
|
+
# Backwards compatibility from when the config was just an array of queues
|
38
|
+
config = { :workers => config } if config.is_a?(Array)
|
39
|
+
unless config && config.is_a?(Hash)
|
40
|
+
raise ArgumentError,
|
41
|
+
"Invalid config file #{config_filename}"
|
42
|
+
end
|
43
|
+
config.with_indifferent_access
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.apply_worker_config!(config)
|
47
|
+
SETTINGS.each do |setting|
|
48
|
+
self.send("#{setting}=", config[setting.to_s]) if config.key?(setting.to_s)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.default_worker_config_name
|
53
|
+
expand_rails_path("config/delayed_jobs.yml")
|
54
|
+
end
|
55
|
+
|
56
|
+
# Expands rails-relative paths, without depending on rails being loaded.
|
57
|
+
def self.expand_rails_path(path)
|
58
|
+
root = if defined?(Rails) && Rails.root
|
59
|
+
(Rails.root+"Gemfile").to_s
|
60
|
+
else
|
61
|
+
ENV.fetch('BUNDLE_GEMFILE')
|
62
|
+
end
|
63
|
+
File.expand_path("../#{path}", root)
|
64
|
+
end
|
31
65
|
end
|
32
66
|
end
|
data/lib/delayed/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: after_transaction_commit
|