stapfen 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Stapfen
2
- VERSION = '1.4.1'
2
+ VERSION = '1.4.2'
3
3
  end
@@ -5,6 +5,9 @@ module Stapfen
5
5
  class Worker
6
6
  include Stapfen::Logger
7
7
 
8
+ @@signals_handled = false
9
+ @@workers = []
10
+
8
11
  class << self
9
12
  attr_accessor :configuration, :consumers, :logger, :destructor
10
13
  attr_accessor :workers
@@ -14,8 +17,7 @@ module Stapfen
14
17
  def self.run!
15
18
  worker = self.new
16
19
 
17
- @workers ||= []
18
- @workers << worker
20
+ @@workers << worker
19
21
 
20
22
  handle_signals
21
23
 
@@ -53,23 +55,29 @@ module Stapfen
53
55
  @destructor = block
54
56
  end
55
57
 
58
+ # Return all the currently running Stapfen::Worker instances in this
59
+ # process
60
+ def self.workers
61
+ @@workers
62
+ end
63
+
56
64
  # Utility method to set up the proper worker signal handlers
57
65
  def self.handle_signals
58
- return if @signals_handled
66
+ return if @@signals_handled
59
67
 
60
68
  Signal.trap(:INT) do
61
- workers.each do |w|
69
+ @@workers.each do |w|
62
70
  w.exit_cleanly
63
71
  end
64
72
  exit!
65
73
  end
66
74
  Signal.trap(:TERM) do
67
- workers.each do |w|
75
+ @@workers.each do |w|
68
76
  w.exit_cleanly
69
77
  end
70
78
  end
71
79
 
72
- @signals_handled = true
80
+ @@signals_handled = true
73
81
  end
74
82
 
75
83
 
@@ -82,7 +90,7 @@ module Stapfen
82
90
 
83
91
  def run
84
92
  @client = Stomp::Client.new(self.class.configuration.call)
85
- debug("Running with #{@client} inside of Thread:#{Thread.current.object_id}")
93
+ debug("Running with #{@client} inside of Thread:#{Thread.current.inspect}")
86
94
 
87
95
  self.class.consumers.each do |name, headers, block|
88
96
  unreceive_headers = {}
@@ -124,6 +132,7 @@ module Stapfen
124
132
  # Invokes the shutdown block if it has been created, and closes the
125
133
  # {{Stomp::Client}} connection unless it has already been shut down
126
134
  def exit_cleanly
135
+ info("#{self} exiting cleanly")
127
136
  self.class.destructor.call if self.class.destructor
128
137
 
129
138
  # Only close the client if we have one sitting around
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stapfen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-07 00:00:00.000000000 Z
12
+ date: 2013-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: stomp
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  version: '0'
64
64
  segments:
65
65
  - 0
66
- hash: -1743593967546898414
66
+ hash: 1191286362645180657
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  none: false
69
69
  requirements:
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  version: '0'
73
73
  segments:
74
74
  - 0
75
- hash: -1743593967546898414
75
+ hash: 1191286362645180657
76
76
  requirements: []
77
77
  rubyforge_project:
78
78
  rubygems_version: 1.8.25