resque-pool 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +8 -2
- data/lib/resque/pool/pooled_worker.rb +2 -46
- data/lib/resque/pool.rb +9 -5
- metadata +7 -8
data/README.md
CHANGED
@@ -26,8 +26,9 @@ To configure resque-pool, you can use either `resque-pool.yml` or
|
|
26
26
|
(`resque/pool/tasks`) in your rake file, and call the `resque:pool` task.
|
27
27
|
|
28
28
|
The YAML file supports both using root level defaults as well as environment
|
29
|
-
specific overrides
|
30
|
-
|
29
|
+
specific overrides (`RACK_ENV`, `RAILS_ENV`, and `RESQUE_ENV` environment
|
30
|
+
variables will be used to determine environment). For example, to use
|
31
|
+
resque-pool with rails, in `config/resque-pool.yml`:
|
31
32
|
|
32
33
|
foo: 1
|
33
34
|
bar: 2
|
@@ -110,6 +111,11 @@ Other Features
|
|
110
111
|
Workers will watch the pool master, and gracefully shutdown if the master
|
111
112
|
process dies (for whatever reason) before them.
|
112
113
|
|
114
|
+
You can specify an alternate config file by setting the `RESQUE_POOL_CONFIG`
|
115
|
+
environment variable like so:
|
116
|
+
|
117
|
+
rake resque:pool RESQUE_ENV=production RESQUE_POOL_CONFIG=/path/to/my/config.yml
|
118
|
+
|
113
119
|
TODO
|
114
120
|
-----
|
115
121
|
|
@@ -11,55 +11,11 @@ class Resque::Pool
|
|
11
11
|
@pool_master_pid && @pool_master_pid != Process.ppid
|
12
12
|
end
|
13
13
|
|
14
|
-
#
|
14
|
+
# override +shutdown?+ method
|
15
15
|
def shutdown?
|
16
|
-
|
16
|
+
super || pool_master_has_gone_away?
|
17
17
|
end
|
18
18
|
|
19
|
-
# this entire method (except for one line) is copied and pasted from
|
20
|
-
# resque-1.9.10. If shutdown were used as a method (attr_reader) rather
|
21
|
-
# than an instance variable, I wouldn't need to reduplicate this. :-(
|
22
|
-
#
|
23
|
-
# hopefully I can get defunkt to accept my patch for this.
|
24
|
-
# Until it is, the resque-pool gem will depend on an exact version of
|
25
|
-
# resque.
|
26
|
-
def work(interval = 5, &block)
|
27
|
-
$0 = "resque: Starting"
|
28
|
-
startup
|
29
|
-
|
30
|
-
loop do
|
31
|
-
#### THIS IS THE ONLY LINE THAT IS CHANGED
|
32
|
-
break if shutdown?
|
33
|
-
#### THAT WAS THE ONLY LINE THAT WAS CHANGED
|
34
|
-
|
35
|
-
if not @paused and job = reserve
|
36
|
-
log "got: #{job.inspect}"
|
37
|
-
run_hook :before_fork, job
|
38
|
-
working_on job
|
39
|
-
|
40
|
-
if @child = fork
|
41
|
-
rand # Reseeding
|
42
|
-
procline "Forked #{@child} at #{Time.now.to_i}"
|
43
|
-
Process.wait
|
44
|
-
else
|
45
|
-
procline "Processing #{job.queue} since #{Time.now.to_i}"
|
46
|
-
perform(job, &block)
|
47
|
-
exit! unless @cant_fork
|
48
|
-
end
|
49
|
-
|
50
|
-
done_working
|
51
|
-
@child = nil
|
52
|
-
else
|
53
|
-
break if interval.to_i == 0
|
54
|
-
log! "Sleeping for #{interval.to_i}"
|
55
|
-
procline @paused ? "Paused" : "Waiting for #{@queues.join(',')}"
|
56
|
-
sleep interval.to_i
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
ensure
|
61
|
-
unregister_worker
|
62
|
-
end
|
63
19
|
end
|
64
20
|
|
65
21
|
end
|
data/lib/resque/pool.rb
CHANGED
@@ -51,15 +51,19 @@ module Resque
|
|
51
51
|
|
52
52
|
@config_files = ["resque-pool.yml", "config/resque-pool.yml"]
|
53
53
|
class << self; attr_accessor :config_files; end
|
54
|
-
def self.
|
55
|
-
|
54
|
+
def self.choose_config_file
|
55
|
+
if ENV["RESQUE_POOL_CONFIG"]
|
56
|
+
ENV["RESQUE_POOL_CONFIG"]
|
57
|
+
else
|
58
|
+
@config_files.detect { |f| File.exist?(f) }
|
59
|
+
end
|
56
60
|
end
|
57
61
|
|
58
62
|
def self.run
|
59
63
|
if GC.respond_to?(:copy_on_write_friendly=)
|
60
64
|
GC.copy_on_write_friendly = true
|
61
65
|
end
|
62
|
-
Resque::Pool.new(
|
66
|
+
Resque::Pool.new(choose_config_file).start.join
|
63
67
|
end
|
64
68
|
|
65
69
|
# }}}
|
@@ -79,8 +83,8 @@ module Resque
|
|
79
83
|
end
|
80
84
|
|
81
85
|
def load_config
|
82
|
-
@config_file
|
83
|
-
@config[environment] and config.merge!(@config[environment])
|
86
|
+
@config_file and @config = YAML.load_file(@config_file)
|
87
|
+
environment and @config[environment] and config.merge!(@config[environment])
|
84
88
|
config.delete_if {|key, value| value.is_a? Hash }
|
85
89
|
end
|
86
90
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 9
|
10
|
+
version: 0.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- nicholas a. evans
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-26 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -38,14 +38,13 @@ dependencies:
|
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
hash:
|
43
|
+
hash: 27
|
44
44
|
segments:
|
45
45
|
- 1
|
46
|
-
- 9
|
47
46
|
- 10
|
48
|
-
version: 1.
|
47
|
+
version: "1.10"
|
49
48
|
type: :runtime
|
50
49
|
version_requirements: *id002
|
51
50
|
description: " quickly and easily fork a pool of resque workers,\n saving memory (w/REE) and monitoring their uptime\n"
|