eventq_rabbitmq 1.5.0 → 1.6.0
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.
- checksums.yaml +4 -4
- data/lib/eventq_rabbitmq/rabbitmq_queue_worker.rb +38 -4
- data/lib/eventq_rabbitmq/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7df8604ee53f1211e41fa4d059c9d2a395d82db9
|
4
|
+
data.tar.gz: 39f7074816e0913dea481bdb2fc03aebe1df570c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e8a53c5d8e4b07e879a8ea4dcd385e8f29b0887ccee48b681c0781b66814b178bf1d3e74b0d4c4d91a8d73c56dbf12e5039394ee7b254d4b4f1b46b909b905d
|
7
|
+
data.tar.gz: 7e6dfffafbc109f945bfc7b2b5753512d4b47c4ab9445e00a6be9a59c7146c10876f0f5949211eb16a754db45c537c3dea8b28efc7adaa4a52925e4f11741bf9
|
@@ -15,6 +15,11 @@ module EventQ
|
|
15
15
|
|
16
16
|
def start(queue, options = {}, &block)
|
17
17
|
|
18
|
+
Signal.trap('TERM') {
|
19
|
+
stop
|
20
|
+
exit
|
21
|
+
}
|
22
|
+
|
18
23
|
EventQ.log(:info, "[#{self.class}] - Preparing to start listening for messages.")
|
19
24
|
|
20
25
|
configure(queue, options)
|
@@ -27,7 +32,26 @@ module EventQ
|
|
27
32
|
|
28
33
|
EventQ.log(:info, "[#{self.class}] - Listening for messages.")
|
29
34
|
|
30
|
-
@
|
35
|
+
@forks = []
|
36
|
+
if @fork_count > 1
|
37
|
+
@fork_count.times do
|
38
|
+
pid = fork do
|
39
|
+
Signal.trap('TERM') { exit }
|
40
|
+
@is_running = true
|
41
|
+
start_process(options, queue, block)
|
42
|
+
end
|
43
|
+
@forks.push(pid)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
@is_running = true
|
47
|
+
start_process(options, queue, block)
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def start_process(options, queue, block)
|
54
|
+
|
31
55
|
@threads = []
|
32
56
|
|
33
57
|
#loop through each thread count
|
@@ -129,7 +153,12 @@ module EventQ
|
|
129
153
|
def stop
|
130
154
|
EventQ.log(:info, "[#{self.class}] - Stopping.")
|
131
155
|
@is_running = false
|
132
|
-
@
|
156
|
+
if @forks.count > 1
|
157
|
+
@forks.each { |pid| Process.kill('TERM', pid) }
|
158
|
+
else
|
159
|
+
@threads.each { |thr| thr.join }
|
160
|
+
end
|
161
|
+
|
133
162
|
return true
|
134
163
|
end
|
135
164
|
|
@@ -204,7 +233,7 @@ module EventQ
|
|
204
233
|
@queue = queue
|
205
234
|
|
206
235
|
#default thread count
|
207
|
-
@thread_count =
|
236
|
+
@thread_count = 4
|
208
237
|
if options.key?(:thread_count)
|
209
238
|
@thread_count = options[:thread_count]
|
210
239
|
end
|
@@ -215,7 +244,12 @@ module EventQ
|
|
215
244
|
@sleep = options[:sleep]
|
216
245
|
end
|
217
246
|
|
218
|
-
|
247
|
+
@fork_count = 1
|
248
|
+
if options.key?(:fork_count)
|
249
|
+
@fork_count = options[:fork_count]
|
250
|
+
end
|
251
|
+
|
252
|
+
EventQ.log(:info, "[#{self.class}] - Configuring. Process Count: #{@fork_count} Thread Count: #{@thread_count} | Interval Sleep: #{@sleep}.")
|
219
253
|
|
220
254
|
return true
|
221
255
|
|