resque-pool 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/.travis.yml +13 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +23 -0
- data/Changelog.md +10 -1
- data/Gemfile +3 -0
- data/Gemfile.lock +102 -0
- data/LICENSE.txt +3 -2
- data/README.md +74 -23
- data/Rakefile +3 -6
- data/config/alternate.yml +4 -0
- data/config/cucumber.yml +2 -0
- data/examples/Gemfile +2 -0
- data/examples/Gemfile.lock +80 -0
- data/examples/Rakefile +8 -0
- data/examples/chef_cookbook/recipes/default.rb +46 -0
- data/examples/chef_cookbook/templates/default/initd.erb +69 -0
- data/examples/chef_cookbook/templates/default/monitrc.erb +6 -0
- data/examples/rails-resque.rake +22 -0
- data/examples/resque-pool.god +43 -0
- data/examples/resque-pool.yml +4 -0
- data/examples/upstart-reload.conf +24 -0
- data/examples/upstart.conf +44 -0
- data/{bin → exe}/resque-pool +0 -0
- data/lib/resque/pool.rb +49 -26
- data/lib/resque/pool/cli.rb +48 -11
- data/lib/resque/pool/config_loaders/file_or_hash_loader.rb +63 -0
- data/lib/resque/pool/config_loaders/throttled.rb +44 -0
- data/lib/resque/pool/killer.rb +40 -0
- data/lib/resque/pool/logging.rb +3 -1
- data/lib/resque/pool/version.rb +1 -1
- data/resque-pool.gemspec +42 -0
- metadata +95 -42
- data/lib/resque/pool/file_or_hash_loader.rb +0 -55
@@ -1,55 +0,0 @@
|
|
1
|
-
class FileOrHashLoader
|
2
|
-
def initialize(filename_or_hash=nil)
|
3
|
-
case filename_or_hash
|
4
|
-
when String, nil
|
5
|
-
@filename = filename_or_hash
|
6
|
-
when Hash
|
7
|
-
@static_config = filename_or_hash.dup
|
8
|
-
else
|
9
|
-
raise "#{self.class} cannot be initialized with #{filename_or_hash.inspect}"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(environment)
|
14
|
-
@config ||= load_config_from_file(environment)
|
15
|
-
end
|
16
|
-
|
17
|
-
def reset!
|
18
|
-
@config = nil
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def load_config_from_file(environment)
|
24
|
-
if @static_config
|
25
|
-
new_config = @static_config
|
26
|
-
else
|
27
|
-
filename = config_filename
|
28
|
-
new_config = load_config filename
|
29
|
-
end
|
30
|
-
apply_environment new_config, environment
|
31
|
-
end
|
32
|
-
|
33
|
-
def apply_environment(config, environment)
|
34
|
-
environment and config[environment] and config.merge!(config[environment])
|
35
|
-
config.delete_if {|key, value| value.is_a? Hash }
|
36
|
-
end
|
37
|
-
|
38
|
-
def config_filename
|
39
|
-
@filename || choose_config_file
|
40
|
-
end
|
41
|
-
|
42
|
-
def load_config(filename)
|
43
|
-
return {} unless filename
|
44
|
-
YAML.load(ERB.new(IO.read(filename)).result)
|
45
|
-
end
|
46
|
-
|
47
|
-
CONFIG_FILES = ["resque-pool.yml", "config/resque-pool.yml"]
|
48
|
-
def choose_config_file
|
49
|
-
if ENV["RESQUE_POOL_CONFIG"]
|
50
|
-
ENV["RESQUE_POOL_CONFIG"]
|
51
|
-
else
|
52
|
-
CONFIG_FILES.detect { |f| File.exist?(f) }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|