dafiti-rabbit-hutch 0.1.1 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- metadata +3 -25
- data/.gitignore +0 -56
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -68
- data/config.yaml +0 -14
- data/configs/.config.yml.swp +0 -0
- data/configs/config.yaml +0 -17
- data/configs/config.yml +0 -17
- data/configs/config2.yaml +0 -51
- data/configs/config_old.yaml +0 -28
- data/configs/configtemplate.yaml +0 -32
- data/configs/webconfig.ru +0 -4
- data/dev_web.sh +0 -1
- data/lib/configurator.rb +0 -38
- data/lib/consumer.rb +0 -32
- data/lib/consumers/console_consumer.rb +0 -21
- data/lib/consumers/log4r_consumer.rb +0 -36
- data/lib/consumers/mongo_consumer.rb +0 -35
- data/lib/logger.rb +0 -16
- data/lib/rabbithutch.rb +0 -78
- data/lib/rabbithutchmgr.rb +0 -48
- data/lib/worker.rb +0 -33
- data/rabbithutch.gemspec +0 -43
- data/rabbithutchservice.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd4de5f90d8fc08d4e47233fbb2473b0cfdfd649b6d958d32f08912ffa9a6975
|
4
|
+
data.tar.gz: d774ad3c3228e7b12e6c62449bb3b49c18bdc7bdd7950a058f41ed585263f1e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f054f0114dd8f73584e71afe7de660300aa5b70296dc619d197110e012160a9a8fdf4ff550336f80973fb3e5c34475f8c82d6f9b1556d4784b636d6b86fac868
|
7
|
+
data.tar.gz: bf06727d9e3ecd9132c57e929e7616dfd58f62992440bf2db5f1c8f3816183197edc3da2502e0b0e51f1d63ab4293192a298dcb025bc9f587cc682abb2d64add
|
data/README.md
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
RabbitMq Trace Logger - Listen to multiple RabbitMq instances and log them to a single location or MongoDb database.
|
1
|
+
test
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dafiti-rabbit-hutch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luiz Bartolomeu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amqp
|
@@ -244,33 +244,10 @@ extra_rdoc_files:
|
|
244
244
|
- LICENSE.txt
|
245
245
|
- README.md
|
246
246
|
files:
|
247
|
-
- ".gitignore"
|
248
|
-
- Gemfile
|
249
|
-
- Gemfile.lock
|
250
247
|
- LICENSE.txt
|
251
248
|
- README.md
|
252
249
|
- bin/rabbithutch
|
253
250
|
- bin/rabbithutchweb
|
254
|
-
- config.yaml
|
255
|
-
- configs/.config.yml.swp
|
256
|
-
- configs/config.yaml
|
257
|
-
- configs/config.yml
|
258
|
-
- configs/config2.yaml
|
259
|
-
- configs/config_old.yaml
|
260
|
-
- configs/configtemplate.yaml
|
261
|
-
- configs/webconfig.ru
|
262
|
-
- dev_web.sh
|
263
|
-
- lib/configurator.rb
|
264
|
-
- lib/consumer.rb
|
265
|
-
- lib/consumers/console_consumer.rb
|
266
|
-
- lib/consumers/log4r_consumer.rb
|
267
|
-
- lib/consumers/mongo_consumer.rb
|
268
|
-
- lib/logger.rb
|
269
|
-
- lib/rabbithutch.rb
|
270
|
-
- lib/rabbithutchmgr.rb
|
271
|
-
- lib/worker.rb
|
272
|
-
- rabbithutch.gemspec
|
273
|
-
- rabbithutchservice.rb
|
274
251
|
- web/public/assets/css/bootstrap-responsive.css
|
275
252
|
- web/public/assets/css/bootstrap-responsive.min.css
|
276
253
|
- web/public/assets/css/bootstrap.css
|
@@ -295,6 +272,7 @@ rdoc_options:
|
|
295
272
|
- "--exclude spec/testfiles"
|
296
273
|
require_paths:
|
297
274
|
- lib
|
275
|
+
- web
|
298
276
|
required_ruby_version: !ruby/object:Gem::Requirement
|
299
277
|
requirements:
|
300
278
|
- - ">="
|
data/.gitignore
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
/.config
|
4
|
-
/coverage/
|
5
|
-
/InstalledFiles
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/spec/examples.txt
|
9
|
-
/test/tmp/
|
10
|
-
/test/version_tmp/
|
11
|
-
/tmp/
|
12
|
-
|
13
|
-
# Used by dotenv library to load environment variables.
|
14
|
-
# .env
|
15
|
-
|
16
|
-
# Ignore Byebug command history file.
|
17
|
-
.byebug_history
|
18
|
-
|
19
|
-
## Specific to RubyMotion:
|
20
|
-
.dat*
|
21
|
-
.repl_history
|
22
|
-
build/
|
23
|
-
*.bridgesupport
|
24
|
-
build-iPhoneOS/
|
25
|
-
build-iPhoneSimulator/
|
26
|
-
|
27
|
-
## Specific to RubyMotion (use of CocoaPods):
|
28
|
-
#
|
29
|
-
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
-
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
-
#
|
33
|
-
# vendor/Pods/
|
34
|
-
|
35
|
-
## Documentation cache and generated files:
|
36
|
-
/.yardoc/
|
37
|
-
/_yardoc/
|
38
|
-
/doc/
|
39
|
-
/rdoc/
|
40
|
-
|
41
|
-
## Environment normalization:
|
42
|
-
/.bundle/
|
43
|
-
/vendor/bundle
|
44
|
-
/lib/bundler/man/
|
45
|
-
|
46
|
-
# for a library or gem, you might want to ignore these files since the code is
|
47
|
-
# intended to run in multiple environments; otherwise, check them in:
|
48
|
-
# Gemfile.lock
|
49
|
-
# .ruby-version
|
50
|
-
# .ruby-gemset
|
51
|
-
|
52
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
-
.rvmrc
|
54
|
-
|
55
|
-
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
-
# .rubocop-https?--*
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rabbithutch (0.1.6)
|
5
|
-
amqp
|
6
|
-
bson_ext
|
7
|
-
daemons
|
8
|
-
eventmachine
|
9
|
-
haml
|
10
|
-
log4r
|
11
|
-
logger
|
12
|
-
mongo
|
13
|
-
mongo_ext
|
14
|
-
mq
|
15
|
-
mustache
|
16
|
-
shotgun
|
17
|
-
sinatra
|
18
|
-
thin
|
19
|
-
thor
|
20
|
-
yard
|
21
|
-
|
22
|
-
GEM
|
23
|
-
remote: https://rubygems.org/
|
24
|
-
specs:
|
25
|
-
amq-client (0.9.10)
|
26
|
-
amq-protocol (>= 0.9.4)
|
27
|
-
eventmachine
|
28
|
-
amq-protocol (1.0.1)
|
29
|
-
amqp (0.9.8)
|
30
|
-
amq-client (~> 0.9.5)
|
31
|
-
amq-protocol (>= 0.9.4)
|
32
|
-
eventmachine
|
33
|
-
bson (1.8.2)
|
34
|
-
bson_ext (1.8.1)
|
35
|
-
bson (~> 1.8.1)
|
36
|
-
daemons (1.1.9)
|
37
|
-
eventmachine (1.0.0)
|
38
|
-
haml (3.1.7)
|
39
|
-
log4r (1.1.10)
|
40
|
-
logger (1.2.8)
|
41
|
-
mongo (1.8.1)
|
42
|
-
bson (~> 1.8.1)
|
43
|
-
mongo_ext (0.19.3)
|
44
|
-
mq (0.1.3)
|
45
|
-
mustache (0.99.4)
|
46
|
-
rack (1.4.4)
|
47
|
-
rack-protection (1.3.2)
|
48
|
-
rack
|
49
|
-
shotgun (0.9)
|
50
|
-
rack (>= 1.0)
|
51
|
-
sinatra (1.3.3)
|
52
|
-
rack (~> 1.3, >= 1.3.6)
|
53
|
-
rack-protection (~> 1.2)
|
54
|
-
tilt (~> 1.3, >= 1.3.3)
|
55
|
-
thin (1.5.0)
|
56
|
-
daemons (>= 1.0.9)
|
57
|
-
eventmachine (>= 0.12.6)
|
58
|
-
rack (>= 1.0.0)
|
59
|
-
thor (0.16.0)
|
60
|
-
tilt (1.3.3)
|
61
|
-
yard (0.8.3)
|
62
|
-
|
63
|
-
PLATFORMS
|
64
|
-
ruby
|
65
|
-
x86-mingw32
|
66
|
-
|
67
|
-
DEPENDENCIES
|
68
|
-
rabbithutch!
|
data/config.yaml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
---
|
2
|
-
application:
|
3
|
-
exchangename: amq.rabbitmq.trace
|
4
|
-
queuename: rabbithutch
|
5
|
-
rabbitmq:
|
6
|
-
hosts:
|
7
|
-
- displayname: local1
|
8
|
-
enabled: true
|
9
|
-
hostname: localhost
|
10
|
-
username: admin
|
11
|
-
password: admin
|
12
|
-
consumers_config:
|
13
|
-
consumers:
|
14
|
-
- name: console_consumer
|
data/configs/.config.yml.swp
DELETED
Binary file
|
data/configs/config.yaml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
application:
|
2
|
-
exchangename: amq.rabbitmq.trace
|
3
|
-
queuename: amq.gen-YxeA_wZnR8TsrqlRPEwNNQ
|
4
|
-
|
5
|
-
rabbitmq:
|
6
|
-
hosts:
|
7
|
-
- displayname: local1
|
8
|
-
enabled: true
|
9
|
-
hostname: localhost
|
10
|
-
username: admin
|
11
|
-
password: admin
|
12
|
-
|
13
|
-
|
14
|
-
consumers_config:
|
15
|
-
consumers:
|
16
|
-
- name: console_consumer
|
17
|
-
|
data/configs/config.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
application:
|
2
|
-
exchangename: amq.rabbitmq.trace
|
3
|
-
queuename: amq.gen-YxeA_wZnR8TsrqlRPEwNNQ
|
4
|
-
|
5
|
-
rabbitmq:
|
6
|
-
hosts:
|
7
|
-
- displayname: local1
|
8
|
-
enabled: true
|
9
|
-
hostname: localhost:15672
|
10
|
-
username: admin
|
11
|
-
password: admin
|
12
|
-
|
13
|
-
|
14
|
-
consumers_config:
|
15
|
-
consumers:
|
16
|
-
- name: console_consumer
|
17
|
-
|
data/configs/config2.yaml
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
---
|
2
|
-
application:
|
3
|
-
exchangename: amq.rabbitmq.trace
|
4
|
-
queuename: rabbithutch
|
5
|
-
rabbitmq:
|
6
|
-
hosts:
|
7
|
-
- id: 1
|
8
|
-
displayname: dev01dd
|
9
|
-
enabled: 'on'
|
10
|
-
hostname: 127.0.0.1dd
|
11
|
-
username: admind
|
12
|
-
password: admin
|
13
|
-
- id: 2
|
14
|
-
displayname: dev02e
|
15
|
-
enabled:
|
16
|
-
hostname: 127.0.0.23
|
17
|
-
username: admin
|
18
|
-
password:
|
19
|
-
- id: 3
|
20
|
-
displayname: QA
|
21
|
-
enabled: false
|
22
|
-
hostname: 127.0.0.3
|
23
|
-
username: admin
|
24
|
-
password: admin
|
25
|
-
- id: 4
|
26
|
-
displayname: STAGING
|
27
|
-
enabled: false
|
28
|
-
hostname: 127.0.0.4
|
29
|
-
username: admin
|
30
|
-
password: admin
|
31
|
-
- id: '7'
|
32
|
-
displayname: dev01dd
|
33
|
-
enabled: 'on'
|
34
|
-
hostname: ee
|
35
|
-
username: eee
|
36
|
-
password: eee
|
37
|
-
consumers_config:
|
38
|
-
consumers:
|
39
|
-
- name: console_consumer
|
40
|
-
enabled: true
|
41
|
-
- name: mongo_consumer
|
42
|
-
enabled: true
|
43
|
-
hostname: 127.0.0.1
|
44
|
-
username: admin
|
45
|
-
password: admin
|
46
|
-
database_prefix: rhutch_
|
47
|
-
port: 27017
|
48
|
-
- name: log4r_consumer
|
49
|
-
enabled: true
|
50
|
-
log_location: /tmp
|
51
|
-
log_prefix: rhutch_
|
data/configs/config_old.yaml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
application:
|
2
|
-
exchangename: amq.rabbitmq.trace
|
3
|
-
queuename: rabbithutch
|
4
|
-
|
5
|
-
rabbitmq:
|
6
|
-
hosts:
|
7
|
-
- id: 1
|
8
|
-
displayname: dev01
|
9
|
-
enabled: true
|
10
|
-
hostname: 127.0.0.1
|
11
|
-
username: admin
|
12
|
-
password: admin
|
13
|
-
|
14
|
-
consumers_config:
|
15
|
-
consumers:
|
16
|
-
- name: console_consumer
|
17
|
-
enabled: true
|
18
|
-
- name: mongo_consumer
|
19
|
-
enabled: true
|
20
|
-
hostname: 127.0.0.1
|
21
|
-
username: admin
|
22
|
-
password: admin
|
23
|
-
database_prefix: rhutch_
|
24
|
-
port: 27017
|
25
|
-
- name: log4r_consumer
|
26
|
-
enabled: true
|
27
|
-
log_location: /tmp
|
28
|
-
log_prefix: rhutch_
|
data/configs/configtemplate.yaml
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
application:
|
2
|
-
exchangename: amq.rabbitmq.trace
|
3
|
-
queuename: rabbithutch
|
4
|
-
|
5
|
-
rabbitmq:
|
6
|
-
hosts:
|
7
|
-
- displayname: localserver
|
8
|
-
enabled: true
|
9
|
-
hostname: 127.0.0.1
|
10
|
-
username: admin
|
11
|
-
password: admin
|
12
|
-
- displayname: anotherserver
|
13
|
-
enabled: false
|
14
|
-
hostname: 127.0.0.2
|
15
|
-
username: admin
|
16
|
-
password: admin
|
17
|
-
|
18
|
-
consumers_config:
|
19
|
-
consumers:
|
20
|
-
- name: console_consumer
|
21
|
-
enabled: true
|
22
|
-
- name: mongo_consumer
|
23
|
-
enabled: true
|
24
|
-
hostname: 127.0.0.1
|
25
|
-
username: admin
|
26
|
-
password: admin
|
27
|
-
database_prefix: rhutch_
|
28
|
-
port: 27017
|
29
|
-
- name: log4r_consumer
|
30
|
-
enabled: true
|
31
|
-
log_location: /tmp
|
32
|
-
log_prefix: rhutch_
|
data/configs/webconfig.ru
DELETED
data/dev_web.sh
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
shotgun ./web/rabbithutchweb.rb
|
data/lib/configurator.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module RabbitHutch
|
4
|
-
class Configurator
|
5
|
-
|
6
|
-
attr_accessor :config
|
7
|
-
|
8
|
-
def initialize options
|
9
|
-
|
10
|
-
file = options['config'] || (File.dirname(__FILE__) + '/../config.yaml')
|
11
|
-
|
12
|
-
puts "Using config from #{file}"
|
13
|
-
|
14
|
-
unless File.exists? file
|
15
|
-
raise "Configuration file [#{file}] doesn't exist"
|
16
|
-
end
|
17
|
-
@config = YAML::load(File.open(file))
|
18
|
-
end
|
19
|
-
|
20
|
-
def application
|
21
|
-
@config['application']
|
22
|
-
end
|
23
|
-
|
24
|
-
def log_config
|
25
|
-
@config['log4r_config']
|
26
|
-
end
|
27
|
-
|
28
|
-
def consumers
|
29
|
-
@config['consumers_config']["consumers"]
|
30
|
-
end
|
31
|
-
|
32
|
-
def rabbitmq_hosts
|
33
|
-
@config['rabbitmq']['hosts']
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
data/lib/consumer.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require_relative "configurator"
|
3
|
-
require_relative "consumers/mongo_consumer"
|
4
|
-
|
5
|
-
module RabbitHutch
|
6
|
-
# Controls the consumers that are to be kicked off based on the config file
|
7
|
-
class Consumer
|
8
|
-
def initialize(consumers)
|
9
|
-
@consumers = consumers
|
10
|
-
end
|
11
|
-
|
12
|
-
# Raised on receipt of a message from RabbitMq and uses the appropriate appender
|
13
|
-
def handle_message(metadata, payload)
|
14
|
-
# loop through appenders and fire each as required
|
15
|
-
@consumers.each do |consumer|
|
16
|
-
action = metadata.routing_key.split('.', 2).first
|
17
|
-
if(action == "publish")
|
18
|
-
exchange = metadata.attributes[:headers]["exchange_name"]
|
19
|
-
queue = metadata.routing_key.split('.', 2).last
|
20
|
-
item = {:date => Time.now,
|
21
|
-
:exchange => exchange,
|
22
|
-
:queue => queue,
|
23
|
-
:routing_keys => metadata.attributes[:headers]["routing_keys"].inspect,
|
24
|
-
:attributes => metadata.attributes.inspect,
|
25
|
-
:payload => payload.inspect
|
26
|
-
}
|
27
|
-
consumer.log_event(item)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rubygems'
|
3
|
-
require "mongo"
|
4
|
-
|
5
|
-
module RabbitHutch
|
6
|
-
class ConsoleConsumer
|
7
|
-
|
8
|
-
def initialize()
|
9
|
-
puts "\tInitializing Console Consumer"
|
10
|
-
end
|
11
|
-
|
12
|
-
def log_event(item)
|
13
|
-
begin
|
14
|
-
puts "console"
|
15
|
-
puts item
|
16
|
-
rescue Exception => e
|
17
|
-
puts "Error occurred Message Handler trying to write messages to Log #{e.inspect}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rubygems'
|
3
|
-
require 'log4r'
|
4
|
-
#require 'log4r/outputter/syslogoutputter'
|
5
|
-
|
6
|
-
module RabbitHutch
|
7
|
-
class Log4rConsumer
|
8
|
-
|
9
|
-
def initialize(rabbitmq_host, config)
|
10
|
-
puts "\tInitializing Log4r Consumer"
|
11
|
-
@rabbitmq_host = rabbitmq_host
|
12
|
-
@config = config
|
13
|
-
@log_name = rabbitmq_host["displayname"]
|
14
|
-
@config.consumers.each do |consumer|
|
15
|
-
if consumer["name"] == 'log4r_consumer'
|
16
|
-
@log_prefix = consumer['log_prefix']
|
17
|
-
@log_location = consumer['log_location']
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
@logger = Log4r::Logger.new("#{@log_name}#_log")
|
23
|
-
@logger.outputters << Log4r::FileOutputter.new("#{@log_name}_filelog", :filename => "#{@log_location}/#{@log_prefix}#{@log_name}.log")
|
24
|
-
end
|
25
|
-
|
26
|
-
def log_event(item)
|
27
|
-
begin
|
28
|
-
puts "log_consumer"
|
29
|
-
@logger.info(item)
|
30
|
-
rescue Exception => e
|
31
|
-
puts "Error occurred Message Handler trying to write messages to Log #{e.inspect}"
|
32
|
-
#@log.error("Error occurred Message Handler trying to write messages to MONGODB #{e.inspect}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rubygems'
|
3
|
-
require "mongo"
|
4
|
-
|
5
|
-
module RabbitHutch
|
6
|
-
class MongoConsumer
|
7
|
-
|
8
|
-
def initialize(rabbitmq_host, config)
|
9
|
-
puts "\tInitializing MongoDb Consumer"
|
10
|
-
@config = config
|
11
|
-
@rabbitmq_host = rabbitmq_host
|
12
|
-
|
13
|
-
@config.consumers.each do |consumer|
|
14
|
-
if consumer["name"] == 'mongo_consumer'
|
15
|
-
@host = consumer['hostname']
|
16
|
-
@port = consumer["port"]
|
17
|
-
@database_prefix = consumer['database_prefix']
|
18
|
-
@database = "#{@database_prefix}#{rabbitmq_host["displayname"]}"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
@connection = Mongo::Connection.new(@host, @port)
|
22
|
-
end
|
23
|
-
|
24
|
-
def log_event(item)
|
25
|
-
begin
|
26
|
-
puts "mongo"
|
27
|
-
db = @connection.db(@database)
|
28
|
-
coll = db.collection(item[:exchange])
|
29
|
-
coll.insert(item)
|
30
|
-
rescue Exception => e
|
31
|
-
puts "Error occurred Message Handler trying to write messages to MONGODB #{e.inspect}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/logger.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'log4r'
|
2
|
-
require 'log4r/yamlconfigurator'
|
3
|
-
require 'log4r/outputter/syslogoutputter'
|
4
|
-
|
5
|
-
class Logger
|
6
|
-
@@log = nil
|
7
|
-
def self.init(config)
|
8
|
-
if !@@log.nil?
|
9
|
-
return @@log
|
10
|
-
end
|
11
|
-
|
12
|
-
configurator = Log4r::YamlConfigurator
|
13
|
-
configurator.decode_yaml config.log_config
|
14
|
-
@@log = Log4r::Logger['main']
|
15
|
-
end
|
16
|
-
end
|
data/lib/rabbithutch.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require "amqp"
|
3
|
-
require_relative "configurator"
|
4
|
-
require_relative "consumers/mongo_consumer"
|
5
|
-
require_relative "consumers/log4r_consumer"
|
6
|
-
require_relative "consumers/console_consumer"
|
7
|
-
require_relative "worker"
|
8
|
-
|
9
|
-
@config = RabbitHutch::Configurator.new({})
|
10
|
-
|
11
|
-
puts "\tEnvironment Settings"
|
12
|
-
@config.rabbitmq_hosts.each do |rabbitmq_host|
|
13
|
-
puts "\tDisplay Name: #{rabbitmq_host["displayname"]}, host: #{rabbitmq_host["hostname"]}, username: #{rabbitmq_host["username"]}, enabled #{rabbitmq_host["enabled"]}"
|
14
|
-
end
|
15
|
-
|
16
|
-
# Initialize all enabled consumners
|
17
|
-
# NOTE: this method will be replaced with a routine to reflect through all valid consumers and initialze them implicitly
|
18
|
-
def initialize_consumers(rabbitmq_host)
|
19
|
-
puts "Initializing Consumers for #{rabbitmq_host["displayname"]}"
|
20
|
-
consumers = []
|
21
|
-
@config.consumers.each do |consumer|
|
22
|
-
# if consumer["enabled"] == true
|
23
|
-
case consumer["name"]
|
24
|
-
when "console_consumer"
|
25
|
-
consumers << RabbitHutch::ConsoleConsumer.new()
|
26
|
-
when "mongo_consumer"
|
27
|
-
consumers << RabbitHutch::MongoConsumer.new(rabbitmq_host, @config)
|
28
|
-
when "log4r_consumer"
|
29
|
-
consumers << RabbitHutch::Log4rConsumer.new(rabbitmq_host, @config)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
#end
|
33
|
-
puts "\tdone"
|
34
|
-
consumers
|
35
|
-
end
|
36
|
-
|
37
|
-
# Start the worker process to listen to a RabbitMq Node
|
38
|
-
def start_worker(rabbitmq_host)
|
39
|
-
displayname = rabbitmq_host["displayname"]
|
40
|
-
hostname = rabbitmq_host["hostname"]
|
41
|
-
username = rabbitmq_host["username"]
|
42
|
-
password = rabbitmq_host["password"]
|
43
|
-
|
44
|
-
consumers = initialize_consumers(rabbitmq_host)
|
45
|
-
|
46
|
-
puts "Listening to RabbitMq #{displayname}, host: #{hostname}, username #{username}"
|
47
|
-
AMQP.connect(:host => hostname, :user => username, :password => password) do |connection|
|
48
|
-
channel = AMQP::Channel.new(connection)
|
49
|
-
worker = RabbitHutch::Worker.new(channel, @config, consumers)
|
50
|
-
worker.start
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Entry Point to the application, Begins queue listener and initializes all consmers
|
55
|
-
def start
|
56
|
-
begin
|
57
|
-
EventMachine.run do
|
58
|
-
|
59
|
-
@config.rabbitmq_hosts.each do |rabbitmq_host|
|
60
|
-
if rabbitmq_host["enabled"] == true
|
61
|
-
start_worker(rabbitmq_host)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
Signal.trap("INT"){EventMachine.stop}
|
65
|
-
Signal.trap("QUIT"){EventMachine.stop}
|
66
|
-
Signal.trap("TERM"){EventMachine.stop}
|
67
|
-
Signal.trap("TSTP"){EventMachine.stop}
|
68
|
-
end
|
69
|
-
rescue Exception=>e
|
70
|
-
puts "#{e.message} #{e.backtrace}"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# Kick off the App
|
75
|
-
start
|
76
|
-
|
77
|
-
|
78
|
-
|
data/lib/rabbithutchmgr.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'mustache'
|
3
|
-
require_relative 'configurator.rb'
|
4
|
-
|
5
|
-
module RabbitHutch
|
6
|
-
#This class controls the Command Line Interface
|
7
|
-
class CLI < Thor
|
8
|
-
|
9
|
-
StandardTemplate =<<-TEMPLATE
|
10
|
-
{{#config}}
|
11
|
-
|
12
|
-
{{#application}}
|
13
|
-
Application
|
14
|
-
+------------------------+------------------------+
|
15
|
-
|Exchange |Queue |
|
16
|
-
+------------------------+------------------------+
|
17
|
-
|{{exchangename}} | {{queuename}} |
|
18
|
-
+------------------------+------------------------+
|
19
|
-
{{/application}}
|
20
|
-
|
21
|
-
{{#rabbitmq}}
|
22
|
-
RabbitMq Servers
|
23
|
-
+------------------------+------------------------+
|
24
|
-
|Display Name |Host |
|
25
|
-
+------------------------+------------------------+
|
26
|
-
{{#hosts}}
|
27
|
-
|{{displayname}} | {{hostname}} |
|
28
|
-
+------------------------+------------------------+
|
29
|
-
{{/hosts}}
|
30
|
-
{{/rabbitmq}}
|
31
|
-
|
32
|
-
{{/config}}
|
33
|
-
TEMPLATE
|
34
|
-
|
35
|
-
desc "list", "List all config settings"
|
36
|
-
#method_option :errors, :aliases => "-e", :type => :boolean, :default => false, :desc => "true = display files that could not be processed, false = do not display skipped files"
|
37
|
-
#method_option :hashtype, :aliases => "-h", :default => "cmd5", :desc => "Choose the hash algorithm to use - md5 or sha"
|
38
|
-
method_option :config, :aliases => "-c", :default => nil, :desc => "parse the config file from a specified location "
|
39
|
-
#method_option :recursive, :aliases => "-r", :type => :boolean, :default => "false", :desc => "true = recurse through sub directories, false = only do top directory"
|
40
|
-
def list()
|
41
|
-
@config = RabbitHutch::Configurator.new(options)
|
42
|
-
puts Mustache.render(StandardTemplate, :config => @config);
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
CLI.start()
|
48
|
-
end
|
data/lib/worker.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "amqp"
|
3
|
-
require_relative "configurator"
|
4
|
-
require_relative "consumer"
|
5
|
-
|
6
|
-
module RabbitHutch
|
7
|
-
@exchange_name = "amq.rabbitmq.trace"
|
8
|
-
|
9
|
-
class Worker
|
10
|
-
|
11
|
-
def initialize(channel, config, consumers)
|
12
|
-
@channel = channel
|
13
|
-
@channel.on_error(&method(:handle_channel_exception))
|
14
|
-
@consumer = Consumer.new(consumers)
|
15
|
-
@exchange_name = config.application['exchangename']
|
16
|
-
@queue_name = config.application['queuename']
|
17
|
-
end
|
18
|
-
|
19
|
-
# begin listening for all topics in publish.#
|
20
|
-
def start
|
21
|
-
@exchange = @channel.topic(@exchange_name, :durable => true, :auto_delete => false, :internal => true)
|
22
|
-
@queue = @channel.queue(@queue_name, :durable => true, :auto_delete => false)
|
23
|
-
@queue.bind(@exchange, :routing_key => 'publish.#')
|
24
|
-
@queue.subscribe(&@consumer.method(:handle_message))
|
25
|
-
end
|
26
|
-
|
27
|
-
def handle_channel_exception(channel, channel_close)
|
28
|
-
puts "Oops... a channel-level exception: code = #{channel_close.reply_code}, message = #{channel_close.reply_text}"
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
data/rabbithutch.gemspec
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
|
5
|
-
Gem::Specification.new do |gem|
|
6
|
-
gem.name = 'dafiti-rabbit-hutch'
|
7
|
-
gem.version = '0.1.1'
|
8
|
-
gem.licenses = ['MIT']
|
9
|
-
gem.summary = "Logger for rabbitMQ!"
|
10
|
-
gem.description = "Logger for rabbitMQ!"
|
11
|
-
gem.authors = ["Luiz Bartolomeu"]
|
12
|
-
gem.email = 'luizbart@gmail.com'
|
13
|
-
gem.files = ["lib/example.rb"]
|
14
|
-
gem.homepage = 'https://rubygems.org/gems/example'
|
15
|
-
gem.metadata = { "source_code_uri" => "https://github.com/ext-luiz-filho/rabbit-hutch" }
|
16
|
-
gem.extra_rdoc_files = ["LICENSE.txt","README.md" ]
|
17
|
-
gem.files = `git ls-files`.split($/)
|
18
|
-
#gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
-
#gem.executable = ['rabbithutch', 'bin/rabbithutch']
|
20
|
-
gem.executables = ['rabbithutch', 'rabbithutchweb']
|
21
|
-
gem.require_paths = ["lib"]
|
22
|
-
|
23
|
-
gem.rdoc_options << '--exclude spec/testfiles'
|
24
|
-
|
25
|
-
gem.add_dependency "amqp"
|
26
|
-
gem.add_dependency "bson_ext"
|
27
|
-
gem.add_dependency "daemons"
|
28
|
-
gem.add_dependency "eventmachine"
|
29
|
-
gem.add_dependency "logger"
|
30
|
-
gem.add_dependency "log4r"
|
31
|
-
gem.add_dependency "mustache"
|
32
|
-
gem.add_dependency "mq"
|
33
|
-
gem.add_dependency "mongo"
|
34
|
-
gem.add_dependency "mongo_ext"
|
35
|
-
gem.add_dependency "thor"
|
36
|
-
gem.add_dependency "yard"
|
37
|
-
|
38
|
-
gem.add_dependency "haml"
|
39
|
-
gem.add_dependency "sinatra"
|
40
|
-
gem.add_dependency "thin"
|
41
|
-
gem.add_dependency "shotgun"
|
42
|
-
|
43
|
-
end
|
data/rabbithutchservice.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'daemons'
|
3
|
-
|
4
|
-
# The Service controller.
|
5
|
-
def start_service
|
6
|
-
begin
|
7
|
-
puts "-------------------------"
|
8
|
-
puts "Starting RabbitHutch #1"
|
9
|
-
Daemons.run(File.dirname(__FILE__) + '/lib/rabbithutch.rb')
|
10
|
-
rescue SystemExit=>e
|
11
|
-
puts e.inspect
|
12
|
-
rescue Exception=>e
|
13
|
-
puts e.inspect
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
start_service()
|
18
|
-
|