smith 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/smithctl +1 -1
- data/lib/smith.rb +18 -18
- data/lib/smith/commands/agency/list.rb +1 -1
- data/lib/smith/commands/smithctl/firehose.rb +18 -6
- data/lib/smith/config.rb +1 -1
- data/lib/smith/version.rb +1 -1
- metadata +40 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9812b89c515ed71a2291f67b53a4c40c519f2afa
|
4
|
+
data.tar.gz: 76b9705aa9b00595d735750b240a594f7bedf79d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efb0730d32b544d91a744fa37f714222d073f19bb94b5474f5e21f8399f5a88ee2e5ba6d8d422691a5a6c1db9d2889ef0674bd48128b683d27eaf2f63f2cad88
|
7
|
+
data.tar.gz: 347b181a6d0980241797c67501ae4c42aa2a479f51577a5e41d5786de4099f6771a44bd695a7972acdca3c6fcfc45b96cf05376dcc0cbe2f7891faf6d105326a
|
data/bin/smithctl
CHANGED
@@ -39,7 +39,7 @@ module Smith
|
|
39
39
|
|
40
40
|
def agency_command(command, args, &blk)
|
41
41
|
Messaging::Sender.new(QueueDefinitions::Agency_control) do |sender|
|
42
|
-
sender.on_timeout(
|
42
|
+
sender.on_timeout(@timeout) { |message_id| blk.call("Timeout. Is the agency still running?") }
|
43
43
|
|
44
44
|
sender.on_reply(:auto_ack => true) do |reply_payload, r|
|
45
45
|
blk.call(reply_payload[:response])
|
data/lib/smith.rb
CHANGED
@@ -75,6 +75,7 @@ module Smith
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def start(opts={}, &block)
|
78
|
+
|
78
79
|
if EM.epoll? && Smith.config.eventmachine.epoll
|
79
80
|
logger.debug { "Using epoll for I/O event notification." }
|
80
81
|
EM.epoll
|
@@ -95,33 +96,27 @@ module Smith
|
|
95
96
|
@connection = connection
|
96
97
|
|
97
98
|
connection.on_connection do
|
98
|
-
|
99
|
-
endpoint = connection.broker_endpoint
|
100
|
-
logger.info { "Connected to: AMQP Broker: #{endpoint}, (#{broker['product']}/v#{broker['version']})" } unless opts[:quiet]
|
99
|
+
logger.info { "Connected to: AMQP Broker: #{broker_identifier(connection)}" } unless opts[:quiet]
|
101
100
|
end
|
102
101
|
|
102
|
+
# FIXME This should go in the config.
|
103
|
+
reconnection_delay = 5
|
104
|
+
|
103
105
|
connection.on_tcp_connection_loss do |connection, settings|
|
104
|
-
|
105
|
-
|
106
|
-
connection.reconnect
|
107
|
-
end
|
106
|
+
logger.info { "Reconnecting to AMQP Broker: #{broker_identifier(connection)} in #{reconnection_delay}s" }
|
107
|
+
connection.reconnect(false, reconnection_delay)
|
108
108
|
end
|
109
109
|
|
110
|
-
connection.after_recovery do
|
111
|
-
logger.info { "Connection
|
110
|
+
connection.after_recovery do |connection|
|
111
|
+
logger.info { "Connection with AMQP Broker restored: #{broker_identifier(connection)}" } unless opts[:quiet]
|
112
112
|
end
|
113
113
|
|
114
114
|
connection.on_error do |connection, connection_close|
|
115
|
-
|
116
|
-
|
117
|
-
logger.warn { "AMQP
|
115
|
+
# If the broker is gracefully shutdown we get a 320. Log a nice message.
|
116
|
+
if connection_close.reply_code == 320
|
117
|
+
logger.warn { "AMQP Broker shutdown: #{broker_identifier(connection)}" }
|
118
118
|
else
|
119
|
-
|
120
|
-
@handler.call(connection, reason)
|
121
|
-
else
|
122
|
-
logger.error { "AMQP Server error: #{connection_close.reply_code}: #{connection_close.reply_text}" }
|
123
|
-
EM.stop_event_loop
|
124
|
-
end
|
119
|
+
logger.warn { connection_close.reply_text }
|
125
120
|
end
|
126
121
|
end
|
127
122
|
|
@@ -190,6 +185,11 @@ module Smith
|
|
190
185
|
end
|
191
186
|
end
|
192
187
|
|
188
|
+
def broker_identifier(connection)
|
189
|
+
broker = connection.broker.properties
|
190
|
+
"#{connection.broker_endpoint}, (#{broker['product']}/v#{broker['version']})"
|
191
|
+
end
|
192
|
+
|
193
193
|
def check_path(path, create=false)
|
194
194
|
unless path.exist?
|
195
195
|
error_message = "Path does not exist: #{path}"
|
@@ -26,7 +26,7 @@ module Smith
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def long_format(a)
|
29
|
-
a.map do |a|
|
29
|
+
a.sort { |a, b| a.name <=> b.name }.map do |a|
|
30
30
|
[a.state, a.uuid, a.pid, (a.started_at) ? format_time(a.started_at) : '', (!(a.stopped? || a.null?) && !a.alive?) ? '(agent dead)' : "", a.name]
|
31
31
|
end
|
32
32
|
end
|
@@ -4,14 +4,21 @@ module Smith
|
|
4
4
|
module Commands
|
5
5
|
class Firehose < CommandBase
|
6
6
|
def execute
|
7
|
-
queue_name = target.first
|
7
|
+
queue_name = target.first || '#'
|
8
8
|
AMQP::Channel.new(Smith.connection) do |channel,ok|
|
9
9
|
channel.topic('amq.rabbitmq.trace', :durable => true) do |exchange|
|
10
10
|
channel.queue('smith.firehose', :durable => true) do |queue|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
if correct_direction?
|
12
|
+
routing_key = "#{options[:direction]}.#{Smith.config.smith.namespace}.#{queue_name}"
|
13
|
+
|
14
|
+
queue.bind(exchange, :routing_key => routing_key).subscribe do |m, payload|
|
15
|
+
acl_type_cache = AclTypeCache.instance
|
16
|
+
clazz = acl_type_cache.get_by_hash(m.headers['properties']['type'])
|
17
|
+
message = {options[:direction] => clazz.new.parse_from_string(payload)}
|
18
|
+
puts (options[:json_given]) ? message.to_json : message.inspect
|
19
|
+
end
|
20
|
+
else
|
21
|
+
responder.succeed("--direction must be either deliver or publish")
|
15
22
|
end
|
16
23
|
end
|
17
24
|
end
|
@@ -24,7 +31,12 @@ module Smith
|
|
24
31
|
" You _must_ run 'rabbitmqctl trace_on' for this to work."]
|
25
32
|
banner b.join("\n")
|
26
33
|
|
27
|
-
opt :json
|
34
|
+
opt :json, "return the JSON representation of the message", :short => :j
|
35
|
+
opt :direction, "Show messages that are leaving the broker [deliver|publish]", :short => :d, :type => :string, :default => 'deliver'
|
36
|
+
end
|
37
|
+
|
38
|
+
def correct_direction?
|
39
|
+
options[:direction] == 'deliver' || options[:direction] == 'publish'
|
28
40
|
end
|
29
41
|
end
|
30
42
|
end
|
data/lib/smith/config.rb
CHANGED
@@ -149,7 +149,7 @@ module Smith
|
|
149
149
|
if conf.exist?
|
150
150
|
return conf
|
151
151
|
else
|
152
|
-
if path == Pathname.new(ENV['HOME'])
|
152
|
+
if path == Pathname.new(ENV['HOME']) || path.root?
|
153
153
|
raise ConfigNotFoundError, "Cannot find a usable config file."
|
154
154
|
end
|
155
155
|
find_config_file(path.dirname)
|
data/lib/smith/version.rb
CHANGED
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Heycock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amqp
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: daemons
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.1.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.1.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: eventmachine
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: extlib
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.9.15
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.9.15
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: logging
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 1.6.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.6.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: protobuf
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - '
|
87
|
+
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 2.7.7
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - '
|
94
|
+
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.7.7
|
97
97
|
- !ruby/object:Gem::Dependency
|
@@ -112,70 +112,70 @@ dependencies:
|
|
112
112
|
name: trollop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 1.16.2
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.16.2
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: multi_json
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: 1.3.2
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 1.3.2
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: ruby_parser
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: 3.2.2
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 3.2.2
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: tdb
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: murmurhash3
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
description: Simple multi-agent framework. It uses AMQP for it's messaging layer.
|
@@ -195,22 +195,22 @@ files:
|
|
195
195
|
- lib/smith/commands/agency/metadata.rb
|
196
196
|
- lib/smith/commands/agency/version.rb
|
197
197
|
- lib/smith/commands/agency/kill.rb
|
198
|
-
- lib/smith/commands/agency/list.rb
|
199
|
-
- lib/smith/commands/agency/logger.rb
|
200
198
|
- lib/smith/commands/agency/object_count.rb
|
201
199
|
- lib/smith/commands/agency/restart.rb
|
202
200
|
- lib/smith/commands/agency/start.rb
|
203
201
|
- lib/smith/commands/agency/stop.rb
|
202
|
+
- lib/smith/commands/agency/logger.rb
|
203
|
+
- lib/smith/commands/agency/list.rb
|
204
204
|
- lib/smith/commands/smithctl/commands.rb
|
205
205
|
- lib/smith/commands/smithctl/pop.rb
|
206
206
|
- lib/smith/commands/smithctl/rm.rb
|
207
207
|
- lib/smith/commands/smithctl/subscribe.rb
|
208
208
|
- lib/smith/commands/smithctl/acl.rb
|
209
209
|
- lib/smith/commands/smithctl/dump.rb
|
210
|
-
- lib/smith/commands/smithctl/firehose.rb
|
211
210
|
- lib/smith/commands/smithctl/push.rb
|
212
211
|
- lib/smith/commands/smithctl/status.rb
|
213
212
|
- lib/smith/commands/smithctl/top.rb
|
213
|
+
- lib/smith/commands/smithctl/firehose.rb
|
214
214
|
- lib/smith/commands/template.rb
|
215
215
|
- lib/smith/commands/common.rb
|
216
216
|
- lib/smith/messaging/acl/agent_command.proto
|
@@ -226,36 +226,37 @@ files:
|
|
226
226
|
- lib/smith/messaging/amqp_options.rb
|
227
227
|
- lib/smith/messaging/message_counter.rb
|
228
228
|
- lib/smith/messaging/queue_factory.rb
|
229
|
-
- lib/smith/messaging/acl_type_cache.rb
|
230
229
|
- lib/smith/messaging/factory.rb
|
231
230
|
- lib/smith/messaging/queue.rb
|
231
|
+
- lib/smith/messaging/requeue.rb
|
232
|
+
- lib/smith/messaging/util.rb
|
233
|
+
- lib/smith/messaging/acl_type_cache.rb
|
232
234
|
- lib/smith/messaging/queue_definition.rb
|
233
235
|
- lib/smith/messaging/receiver.rb
|
234
|
-
- lib/smith/messaging/requeue.rb
|
235
236
|
- lib/smith/messaging/sender.rb
|
236
|
-
- lib/smith/messaging/util.rb
|
237
237
|
- lib/smith/agent_config.rb
|
238
238
|
- lib/smith/object_count.rb
|
239
239
|
- lib/smith/amqp_errors.rb
|
240
240
|
- lib/smith/command_base.rb
|
241
|
-
- lib/smith/
|
241
|
+
- lib/smith/bootstrap.rb
|
242
|
+
- lib/smith/config.rb
|
243
|
+
- lib/smith/queue_definitions.rb
|
242
244
|
- lib/smith/acl_parser.rb
|
243
245
|
- lib/smith/agent.rb
|
244
246
|
- lib/smith/agent_cache.rb
|
245
247
|
- lib/smith/agent_monitoring.rb
|
246
248
|
- lib/smith/agent_process.rb
|
247
|
-
- lib/smith/bootstrap.rb
|
248
249
|
- lib/smith/cache.rb
|
249
|
-
- lib/smith/command.rb
|
250
|
-
- lib/smith/config.rb
|
251
|
-
- lib/smith/daemon.rb
|
252
250
|
- lib/smith/exceptions.rb
|
253
251
|
- lib/smith/logger.rb
|
254
|
-
- lib/smith/
|
252
|
+
- lib/smith/acl_compiler.rb
|
253
|
+
- lib/smith/command.rb
|
254
|
+
- lib/smith/daemon.rb
|
255
255
|
- lib/smith/version.rb
|
256
256
|
- lib/smith.rb
|
257
257
|
homepage: http://github.com/filterfish/smith2
|
258
|
-
licenses:
|
258
|
+
licenses:
|
259
|
+
- GPL-3
|
259
260
|
metadata: {}
|
260
261
|
post_install_message:
|
261
262
|
rdoc_options: []
|
@@ -263,12 +264,12 @@ require_paths:
|
|
263
264
|
- lib
|
264
265
|
required_ruby_version: !ruby/object:Gem::Requirement
|
265
266
|
requirements:
|
266
|
-
- -
|
267
|
+
- - ">="
|
267
268
|
- !ruby/object:Gem::Version
|
268
269
|
version: '0'
|
269
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
271
|
requirements:
|
271
|
-
- -
|
272
|
+
- - ">="
|
272
273
|
- !ruby/object:Gem::Version
|
273
274
|
version: '0'
|
274
275
|
requirements: []
|