eventq_rabbitmq 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7aa16b2923d64f7b515ccaea93fc12aa01b49c6f
4
- data.tar.gz: 233d46ca9e4e29b032c64a766c9ebc5f8a3bd47d
3
+ metadata.gz: 7df8604ee53f1211e41fa4d059c9d2a395d82db9
4
+ data.tar.gz: 39f7074816e0913dea481bdb2fc03aebe1df570c
5
5
  SHA512:
6
- metadata.gz: e0bc9f0b695e2da201e94fb046e25ff6e49d17118308abff7cdd2e3542801e2b1b3cabf23d28ebcc2681843571f069ad6980a3802a748629f42dab2c8f7aa9d0
7
- data.tar.gz: c72e5746d0d1f7f5ea910ebeacee3848931174231ed7f403c9b8075f2d2c6d5a26255cd7feac8e65f7ec61b4cb2b1ea4a1be1666873f30d809dd0bb71bfff785
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
- @is_running = true
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
- @threads.each { |thr| thr.join }
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 = 5
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
- EventQ.log(:info, "[#{self.class}] - Configuring. Thread Count: #{@thread_count} | Interval Sleep: #{@sleep}.")
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
 
@@ -1,3 +1,3 @@
1
1
  module EventqRabbitmq
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventq_rabbitmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage