resque-multi-job-forks 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/resque-multi-job-forks.rb +37 -4
- metadata +30 -13
- checksums.yaml +0 -7
@@ -7,7 +7,11 @@ module Resque
|
|
7
7
|
attr_accessor :jobs_per_fork
|
8
8
|
attr_reader :jobs_processed
|
9
9
|
|
10
|
-
|
10
|
+
def self.multi_jobs_per_fork?
|
11
|
+
ENV["DISABLE_MULTI_JOBS_PER_FORK"].nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
if multi_jobs_per_fork? && !method_defined?(:shutdown_without_multi_job_forks)
|
11
15
|
def perform_with_multi_job_forks(job = nil)
|
12
16
|
perform_without_multi_job_forks(job)
|
13
17
|
hijack_fork unless fork_hijacked?
|
@@ -16,12 +20,26 @@ module Resque
|
|
16
20
|
alias_method :perform_without_multi_job_forks, :perform
|
17
21
|
alias_method :perform, :perform_with_multi_job_forks
|
18
22
|
|
19
|
-
def shutdown_with_multi_job_forks
|
23
|
+
def shutdown_with_multi_job_forks?
|
20
24
|
release_fork if fork_hijacked? && (fork_job_limit_reached? || @shutdown)
|
25
|
+
shutdown_without_multi_job_forks?
|
26
|
+
end
|
27
|
+
alias_method :shutdown_without_multi_job_forks?, :shutdown?
|
28
|
+
alias_method :shutdown?, :shutdown_with_multi_job_forks?
|
29
|
+
|
30
|
+
def shutdown_with_multi_job_forks
|
21
31
|
shutdown_without_multi_job_forks
|
32
|
+
shutdown_child if is_parent_process?
|
22
33
|
end
|
23
|
-
alias_method :shutdown_without_multi_job_forks, :shutdown
|
24
|
-
alias_method :shutdown
|
34
|
+
alias_method :shutdown_without_multi_job_forks, :shutdown
|
35
|
+
alias_method :shutdown, :shutdown_with_multi_job_forks
|
36
|
+
|
37
|
+
def pause_processing_with_multi_job_forks
|
38
|
+
pause_processing_without_multi_job_forks
|
39
|
+
shutdown_child if is_parent_process?
|
40
|
+
end
|
41
|
+
alias_method :pause_processing_without_multi_job_forks, :pause_processing
|
42
|
+
alias_method :pause_processing, :pause_processing_with_multi_job_forks
|
25
43
|
|
26
44
|
def working_on_with_worker_registration(job)
|
27
45
|
register_worker
|
@@ -31,6 +49,20 @@ module Resque
|
|
31
49
|
alias_method :working_on, :working_on_with_worker_registration
|
32
50
|
end
|
33
51
|
|
52
|
+
# Need to tell the child to shutdown since it might be looping performing multiple jobs per fork
|
53
|
+
# The TSTP signal is registered only in forked processes and calls this function
|
54
|
+
def shutdown_child
|
55
|
+
begin
|
56
|
+
Process.kill('TSTP', @child)
|
57
|
+
rescue Errno::ESRCH
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def is_parent_process?
|
63
|
+
@child
|
64
|
+
end
|
65
|
+
|
34
66
|
def fork_hijacked?
|
35
67
|
@release_fork_limit
|
36
68
|
end
|
@@ -42,6 +74,7 @@ module Resque
|
|
42
74
|
@release_fork_limit = fork_job_limit
|
43
75
|
@jobs_processed = 0
|
44
76
|
@cant_fork = true
|
77
|
+
trap('TSTP') { shutdown }
|
45
78
|
end
|
46
79
|
|
47
80
|
def release_fork
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-multi-job-forks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Mick Staugaard
|
@@ -10,11 +11,12 @@ authors:
|
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2013-
|
14
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: resque
|
17
18
|
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
18
20
|
requirements:
|
19
21
|
- - '='
|
20
22
|
- !ruby/object:Gem::Version
|
@@ -22,6 +24,7 @@ dependencies:
|
|
22
24
|
type: :runtime
|
23
25
|
prerelease: false
|
24
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
25
28
|
requirements:
|
26
29
|
- - '='
|
27
30
|
- !ruby/object:Gem::Version
|
@@ -29,43 +32,49 @@ dependencies:
|
|
29
32
|
- !ruby/object:Gem::Dependency
|
30
33
|
name: json
|
31
34
|
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
32
36
|
requirements:
|
33
|
-
- - '>='
|
37
|
+
- - ! '>='
|
34
38
|
- !ruby/object:Gem::Version
|
35
39
|
version: '0'
|
36
40
|
type: :runtime
|
37
41
|
prerelease: false
|
38
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
39
44
|
requirements:
|
40
|
-
- - '>='
|
45
|
+
- - ! '>='
|
41
46
|
- !ruby/object:Gem::Version
|
42
47
|
version: '0'
|
43
48
|
- !ruby/object:Gem::Dependency
|
44
49
|
name: rake
|
45
50
|
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
46
52
|
requirements:
|
47
|
-
- - '>='
|
53
|
+
- - ! '>='
|
48
54
|
- !ruby/object:Gem::Version
|
49
55
|
version: '0'
|
50
56
|
type: :development
|
51
57
|
prerelease: false
|
52
58
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
53
60
|
requirements:
|
54
|
-
- - '>='
|
61
|
+
- - ! '>='
|
55
62
|
- !ruby/object:Gem::Version
|
56
63
|
version: '0'
|
57
64
|
- !ruby/object:Gem::Dependency
|
58
65
|
name: bundler
|
59
66
|
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
60
68
|
requirements:
|
61
|
-
- - '>='
|
69
|
+
- - ! '>='
|
62
70
|
- !ruby/object:Gem::Version
|
63
71
|
version: '0'
|
64
72
|
type: :development
|
65
73
|
prerelease: false
|
66
74
|
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
67
76
|
requirements:
|
68
|
-
- - '>='
|
77
|
+
- - ! '>='
|
69
78
|
- !ruby/object:Gem::Version
|
70
79
|
version: '0'
|
71
80
|
description: When your resque jobs are frequent and fast, the overhead of forking
|
@@ -73,6 +82,7 @@ description: When your resque jobs are frequent and fast, the overhead of forkin
|
|
73
82
|
email:
|
74
83
|
- mick@zendesk.com
|
75
84
|
- luke@lividpenguin.com
|
85
|
+
- sergei.tulentsev@gmail.com
|
76
86
|
executables: []
|
77
87
|
extensions: []
|
78
88
|
extra_rdoc_files: []
|
@@ -82,26 +92,33 @@ files:
|
|
82
92
|
- test/test_resque-multi-job-forks.rb
|
83
93
|
homepage: http://github.com/staugaard/resque-multi-job-forks
|
84
94
|
licenses: []
|
85
|
-
metadata: {}
|
86
95
|
post_install_message:
|
87
96
|
rdoc_options: []
|
88
97
|
require_paths:
|
89
98
|
- lib
|
90
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
91
101
|
requirements:
|
92
|
-
- - '>='
|
102
|
+
- - ! '>='
|
93
103
|
- !ruby/object:Gem::Version
|
94
104
|
version: '0'
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
hash: -218331168347002262
|
95
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
96
110
|
requirements:
|
97
|
-
- - '>='
|
111
|
+
- - ! '>='
|
98
112
|
- !ruby/object:Gem::Version
|
99
113
|
version: '0'
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
hash: -218331168347002262
|
100
117
|
requirements: []
|
101
118
|
rubyforge_project:
|
102
|
-
rubygems_version:
|
119
|
+
rubygems_version: 1.8.25
|
103
120
|
signing_key:
|
104
|
-
specification_version:
|
121
|
+
specification_version: 3
|
105
122
|
summary: Have your resque workers process more that one job
|
106
123
|
test_files:
|
107
124
|
- test/helper.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 547447affcd4597d097b19c334aa1f7f6120343c
|
4
|
-
data.tar.gz: 2d34261455cc8c9c68e55f14c9feef725294db9d
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 8c525dd9d2df30ff8ca51e91eedd33137237b34d6abfbb907ceab4da9746487714dcf1615c0f0da06c12b1a813a62101d20e4040a44d992fa4753392d66d2985
|
7
|
-
data.tar.gz: c5edd7346d4877acb0dd7365e870a6c28c0fb71cd804037f7e53c72019202bd7b6e3bf9195f2fd6935c2973ec08bd119751df86aa60ebc0947c254326ac59cce
|