rabbithutch 0.0.6 → 0.0.7
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.
- data/.gitignore +24 -24
- data/Gemfile +4 -4
- data/Gemfile.lock +53 -54
- data/LICENSE.txt +21 -21
- data/README.md +105 -105
- data/bin/rabbithutch +1 -1
- data/config.yaml +32 -32
- data/lib/configurator.rb +38 -38
- data/lib/consumer.rb +31 -31
- data/lib/consumers/console_consumer.rb +20 -20
- data/lib/consumers/log4r_consumer.rb +35 -34
- data/lib/consumers/mongo_consumer.rb +33 -33
- data/lib/rabbithutch.rb +83 -83
- data/lib/worker.rb +31 -31
- data/rabbithutch.gemspec +35 -35
- data/rabbithutchservice.rb +16 -16
- data/rakefile +5 -5
- metadata +3 -3
- data/lib/logger.rb +0 -18
data/.gitignore
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
*~
|
2
|
-
*.gem
|
3
|
-
*.rbc
|
4
|
-
.bundle
|
5
|
-
.config
|
6
|
-
coverage
|
7
|
-
InstalledFiles
|
8
|
-
lib/bundler/man
|
9
|
-
pkg
|
10
|
-
rdoc
|
11
|
-
spec/reports
|
12
|
-
test/tmp
|
13
|
-
test/version_tmp
|
14
|
-
tmp
|
15
|
-
|
16
|
-
# YARD artifacts
|
17
|
-
.yardoc
|
18
|
-
_yardoc
|
19
|
-
doc/
|
20
|
-
|
21
|
-
.project
|
22
|
-
*.pid
|
23
|
-
|
24
|
-
|
1
|
+
*~
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
coverage
|
7
|
+
InstalledFiles
|
8
|
+
lib/bundler/man
|
9
|
+
pkg
|
10
|
+
rdoc
|
11
|
+
spec/reports
|
12
|
+
test/tmp
|
13
|
+
test/version_tmp
|
14
|
+
tmp
|
15
|
+
|
16
|
+
# YARD artifacts
|
17
|
+
.yardoc
|
18
|
+
_yardoc
|
19
|
+
doc/
|
20
|
+
|
21
|
+
.project
|
22
|
+
*.pid
|
23
|
+
|
24
|
+
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in hash-that-tree.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in hash-that-tree.gemspec
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,54 +1,53 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rabbithutch (0.0.
|
5
|
-
amqp
|
6
|
-
bson_ext
|
7
|
-
daemons
|
8
|
-
eventmachine
|
9
|
-
log4r
|
10
|
-
logger
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
amq-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
rabbithutch!
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rabbithutch (0.0.6)
|
5
|
+
amqp
|
6
|
+
bson_ext
|
7
|
+
daemons
|
8
|
+
eventmachine
|
9
|
+
log4r
|
10
|
+
logger
|
11
|
+
mongo
|
12
|
+
mongo_ext
|
13
|
+
mq
|
14
|
+
thor
|
15
|
+
yard
|
16
|
+
|
17
|
+
GEM
|
18
|
+
remote: https://rubygems.org/
|
19
|
+
specs:
|
20
|
+
activesupport (3.2.9)
|
21
|
+
i18n (~> 0.6)
|
22
|
+
multi_json (~> 1.0)
|
23
|
+
amq-client (0.9.9)
|
24
|
+
amq-protocol (>= 0.9.4)
|
25
|
+
eventmachine
|
26
|
+
amq-protocol (1.0.0)
|
27
|
+
amqp (0.9.8)
|
28
|
+
amq-client (~> 0.9.5)
|
29
|
+
amq-protocol (>= 0.9.4)
|
30
|
+
eventmachine
|
31
|
+
bson (1.8.0)
|
32
|
+
activesupport
|
33
|
+
bson_ext (1.8.0)
|
34
|
+
bson (~> 1.8.0)
|
35
|
+
daemons (1.1.9)
|
36
|
+
eventmachine (1.0.0)
|
37
|
+
i18n (0.6.1)
|
38
|
+
log4r (1.1.10)
|
39
|
+
logger (1.2.8)
|
40
|
+
mongo (1.8.0)
|
41
|
+
bson (~> 1.8.0)
|
42
|
+
mongo_ext (0.19.3)
|
43
|
+
mq (0.1.3)
|
44
|
+
multi_json (1.3.7)
|
45
|
+
thor (0.16.0)
|
46
|
+
yard (0.8.3)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
x86-mingw32
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
rabbithutch!
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2012 John Ryan
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
1
|
+
Copyright (c) 2012 John Ryan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,105 +1,105 @@
|
|
1
|
-
#rabbit-hutch
|
2
|
-
|
3
|
-
RabbitMq Trace Logger - Listen to multiple RabbitMq instances and log them to a
|
4
|
-
single location or MongoDb database.
|
5
|
-
|
6
|
-
# Overview
|
7
|
-
|
8
|
-
A ruby service for monotoring the trace output on RabbitMq Nodes and writing the
|
9
|
-
output to console, Log files or MongoDb.
|
10
|
-
|
11
|
-
Once tracing is started on the target rabbitMQ nodes, the service creates a queue
|
12
|
-
"rabbithutch" that binds to the exchange "amq.rabbitmq.trace". All messages that arrive
|
13
|
-
on the queue are then picked up by any registered consumers and written to standard
|
14
|
-
output, a log file or a MongoDb Database.
|
15
|
-
|
16
|
-
# Environment
|
17
|
-
|
18
|
-
* Linux
|
19
|
-
* Windows
|
20
|
-
|
21
|
-
# Installation
|
22
|
-
|
23
|
-
##Activate tracing on rabbitmq server
|
24
|
-
|
25
|
-
run the following command on each server you want to trace
|
26
|
-
rabbitmqctl trace_on
|
27
|
-
|
28
|
-
##Install the rabbit-hutch service
|
29
|
-
|
30
|
-
gem install rabbithutch
|
31
|
-
|
32
|
-
# Usage
|
33
|
-
|
34
|
-
Run as a command line process with a config file
|
35
|
-
rabbithutch run -- ~/config.yaml
|
36
|
-
|
37
|
-
Run as a service
|
38
|
-
rabbithutch start -- ~/config.yaml
|
39
|
-
|
40
|
-
For help on the service
|
41
|
-
rabbithutch
|
42
|
-
|
43
|
-
# Configuration
|
44
|
-
|
45
|
-
To add RabbitMq nodes to monitor and consumers to enable you will need to change the configuration.
|
46
|
-
|
47
|
-
The config below shows two RabbitMq nodes with each with console, mongoDb and log file consumers
|
48
|
-
|
49
|
-
./config.yaml
|
50
|
-
|
51
|
-
application:
|
52
|
-
exchangename: amq.rabbitmq.trace
|
53
|
-
queuename: rabbithutch
|
54
|
-
|
55
|
-
rabbitmq:
|
56
|
-
hosts:
|
57
|
-
- displayname: local1
|
58
|
-
enabled: true
|
59
|
-
hostname: 127.0.0.1
|
60
|
-
username: guest
|
61
|
-
password: guest
|
62
|
-
- displayname: local2
|
63
|
-
enabled: false
|
64
|
-
hostname: 127.2.2.2
|
65
|
-
username: guest
|
66
|
-
password: guest
|
67
|
-
|
68
|
-
consumers_config:
|
69
|
-
consumers:
|
70
|
-
- name: console_consumer
|
71
|
-
enabled: true
|
72
|
-
- name: mongo_consumer
|
73
|
-
enabled: true
|
74
|
-
hostname: 127.0.0.1
|
75
|
-
username: guest
|
76
|
-
password: guest
|
77
|
-
database_prefix: rhutch_
|
78
|
-
port: 27017
|
79
|
-
- name: log4r_consumer
|
80
|
-
enabled: true
|
81
|
-
log_location: /tmp
|
82
|
-
log_prefix: rhutch_
|
83
|
-
|
84
|
-
#Contributing
|
85
|
-
|
86
|
-
Fork it
|
87
|
-
Create your feature branch (git checkout -b my-new-feature)
|
88
|
-
Commit your changes (git commit -am 'Add some feature')
|
89
|
-
Push to the branch (git push origin my-new-feature)
|
90
|
-
Create new Pull Request
|
91
|
-
|
92
|
-
## Create the gem
|
93
|
-
|
94
|
-
Build and Test Locally
|
95
|
-
-gem build rabbithutch.gemspec
|
96
|
-
-gem install rabbithutch-X.X.X # where X.X.X is the version of the compiled gemspec
|
97
|
-
|
98
|
-
Build and deploy to rubygems.org
|
99
|
-
-gem update --system
|
100
|
-
-gem build rabbithutch.gemspec
|
101
|
-
-gem push rabbithutch-0.0.1.gem # where X.X.X is the version of the compiled gemspec
|
102
|
-
|
103
|
-
|
104
|
-
References
|
105
|
-
|
1
|
+
#rabbit-hutch
|
2
|
+
|
3
|
+
RabbitMq Trace Logger - Listen to multiple RabbitMq instances and log them to a
|
4
|
+
single location or MongoDb database.
|
5
|
+
|
6
|
+
# Overview
|
7
|
+
|
8
|
+
A ruby service for monotoring the trace output on RabbitMq Nodes and writing the
|
9
|
+
output to console, Log files or MongoDb.
|
10
|
+
|
11
|
+
Once tracing is started on the target rabbitMQ nodes, the service creates a queue
|
12
|
+
"rabbithutch" that binds to the exchange "amq.rabbitmq.trace". All messages that arrive
|
13
|
+
on the queue are then picked up by any registered consumers and written to standard
|
14
|
+
output, a log file or a MongoDb Database.
|
15
|
+
|
16
|
+
# Environment
|
17
|
+
|
18
|
+
* Linux
|
19
|
+
* Windows
|
20
|
+
|
21
|
+
# Installation
|
22
|
+
|
23
|
+
##Activate tracing on rabbitmq server
|
24
|
+
|
25
|
+
run the following command on each server you want to trace
|
26
|
+
rabbitmqctl trace_on
|
27
|
+
|
28
|
+
##Install the rabbit-hutch service
|
29
|
+
|
30
|
+
gem install rabbithutch
|
31
|
+
|
32
|
+
# Usage
|
33
|
+
|
34
|
+
Run as a command line process with a config file
|
35
|
+
rabbithutch run -- ~/config.yaml
|
36
|
+
|
37
|
+
Run as a service
|
38
|
+
rabbithutch start -- ~/config.yaml
|
39
|
+
|
40
|
+
For help on the service
|
41
|
+
rabbithutch
|
42
|
+
|
43
|
+
# Configuration
|
44
|
+
|
45
|
+
To add RabbitMq nodes to monitor and consumers to enable you will need to change the configuration.
|
46
|
+
|
47
|
+
The config below shows two RabbitMq nodes with each with console, mongoDb and log file consumers
|
48
|
+
|
49
|
+
./config.yaml
|
50
|
+
|
51
|
+
application:
|
52
|
+
exchangename: amq.rabbitmq.trace
|
53
|
+
queuename: rabbithutch
|
54
|
+
|
55
|
+
rabbitmq:
|
56
|
+
hosts:
|
57
|
+
- displayname: local1
|
58
|
+
enabled: true
|
59
|
+
hostname: 127.0.0.1
|
60
|
+
username: guest
|
61
|
+
password: guest
|
62
|
+
- displayname: local2
|
63
|
+
enabled: false
|
64
|
+
hostname: 127.2.2.2
|
65
|
+
username: guest
|
66
|
+
password: guest
|
67
|
+
|
68
|
+
consumers_config:
|
69
|
+
consumers:
|
70
|
+
- name: console_consumer
|
71
|
+
enabled: true
|
72
|
+
- name: mongo_consumer
|
73
|
+
enabled: true
|
74
|
+
hostname: 127.0.0.1
|
75
|
+
username: guest
|
76
|
+
password: guest
|
77
|
+
database_prefix: rhutch_
|
78
|
+
port: 27017
|
79
|
+
- name: log4r_consumer
|
80
|
+
enabled: true
|
81
|
+
log_location: /tmp
|
82
|
+
log_prefix: rhutch_
|
83
|
+
|
84
|
+
#Contributing
|
85
|
+
|
86
|
+
Fork it
|
87
|
+
Create your feature branch (git checkout -b my-new-feature)
|
88
|
+
Commit your changes (git commit -am 'Add some feature')
|
89
|
+
Push to the branch (git push origin my-new-feature)
|
90
|
+
Create new Pull Request
|
91
|
+
|
92
|
+
## Create the gem
|
93
|
+
|
94
|
+
Build and Test Locally
|
95
|
+
-gem build rabbithutch.gemspec
|
96
|
+
-gem install rabbithutch-X.X.X # where X.X.X is the version of the compiled gemspec
|
97
|
+
|
98
|
+
Build and deploy to rubygems.org
|
99
|
+
-gem update --system
|
100
|
+
-gem build rabbithutch.gemspec
|
101
|
+
-gem push rabbithutch-0.0.1.gem # where X.X.X is the version of the compiled gemspec
|
102
|
+
|
103
|
+
|
104
|
+
References
|
105
|
+
|
data/bin/rabbithutch
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require_relative '../rabbithutchservice.rb'
|
1
|
+
require_relative '../rabbithutchservice.rb'
|
data/config.yaml
CHANGED
@@ -1,32 +1,32 @@
|
|
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: guest
|
11
|
-
password: guest
|
12
|
-
- displayname: anotherserver
|
13
|
-
enabled: false
|
14
|
-
hostname: 127.0.0.2
|
15
|
-
username: guest
|
16
|
-
password: guest
|
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: guest
|
26
|
-
password: guest
|
27
|
-
database_prefix: rhutch_
|
28
|
-
port: 27017
|
29
|
-
- name: log4r_consumer
|
30
|
-
enabled: true
|
31
|
-
log_location: /tmp
|
32
|
-
log_prefix: rhutch_
|
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: guest
|
11
|
+
password: guest
|
12
|
+
- displayname: anotherserver
|
13
|
+
enabled: false
|
14
|
+
hostname: 127.0.0.2
|
15
|
+
username: guest
|
16
|
+
password: guest
|
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: guest
|
26
|
+
password: guest
|
27
|
+
database_prefix: rhutch_
|
28
|
+
port: 27017
|
29
|
+
- name: log4r_consumer
|
30
|
+
enabled: true
|
31
|
+
log_location: /tmp
|
32
|
+
log_prefix: rhutch_
|
data/lib/configurator.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module RabbitHutch
|
4
|
-
class Configurator
|
5
|
-
|
6
|
-
attr_accessor :config
|
7
|
-
|
8
|
-
def initialize options
|
9
|
-
|
10
|
-
file = ARGV[0] || (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
|
-
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module RabbitHutch
|
4
|
+
class Configurator
|
5
|
+
|
6
|
+
attr_accessor :config
|
7
|
+
|
8
|
+
def initialize options
|
9
|
+
|
10
|
+
file = ARGV[0] || (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
CHANGED
@@ -1,32 +1,32 @@
|
|
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
|
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
32
|
end
|
@@ -1,20 +1,20 @@
|
|
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 item
|
15
|
-
rescue Exception => e
|
16
|
-
puts "Error occurred Message Handler trying to write messages to Log #{e.inspect}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
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 item
|
15
|
+
rescue Exception => e
|
16
|
+
puts "Error occurred Message Handler trying to write messages to Log #{e.inspect}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,34 +1,35 @@
|
|
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
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
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
|
+
@logger.info(item)
|
29
|
+
rescue Exception => e
|
30
|
+
puts "Error occurred Message Handler trying to write messages to Log #{e.inspect}"
|
31
|
+
#@log.error("Error occurred Message Handler trying to write messages to MONGODB #{e.inspect}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,33 +1,33 @@
|
|
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
|
-
@host = rabbitmq_host["hostname"]
|
13
|
-
@config.consumers.each do |consumer|
|
14
|
-
if consumer["name"] == 'mongo_consumer'
|
15
|
-
@database_prefix = consumer['database_prefix']
|
16
|
-
end
|
17
|
-
end
|
18
|
-
@database = "#{@database_prefix}#{rabbitmq_host["displayname"]}"
|
19
|
-
@port = rabbitmq_host["port"]
|
20
|
-
@connection = Mongo::Connection.new(@host, @port)
|
21
|
-
end
|
22
|
-
|
23
|
-
def log_event(item)
|
24
|
-
begin
|
25
|
-
db = @connection.db(@database)
|
26
|
-
coll = db.collection(item[:exchange])
|
27
|
-
coll.insert(item)
|
28
|
-
rescue Exception => e
|
29
|
-
puts "Error occurred Message Handler trying to write messages to MONGODB #{e.inspect}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
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
|
+
@host = rabbitmq_host["hostname"]
|
13
|
+
@config.consumers.each do |consumer|
|
14
|
+
if consumer["name"] == 'mongo_consumer'
|
15
|
+
@database_prefix = consumer['database_prefix']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
@database = "#{@database_prefix}#{rabbitmq_host["displayname"]}"
|
19
|
+
@port = rabbitmq_host["port"]
|
20
|
+
@connection = Mongo::Connection.new(@host, @port)
|
21
|
+
end
|
22
|
+
|
23
|
+
def log_event(item)
|
24
|
+
begin
|
25
|
+
db = @connection.db(@database)
|
26
|
+
coll = db.collection(item[:exchange])
|
27
|
+
coll.insert(item)
|
28
|
+
rescue Exception => e
|
29
|
+
puts "Error occurred Message Handler trying to write messages to MONGODB #{e.inspect}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/rabbithutch.rb
CHANGED
@@ -1,83 +1,83 @@
|
|
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
|
-
@log = nil #RabbitHutch::MyLogger.init(@config)
|
11
|
-
|
12
|
-
puts "-------------------------"
|
13
|
-
puts "Starting RabbitHutch"
|
14
|
-
puts "\tEnvironment Settings"
|
15
|
-
@config.rabbitmq_hosts.each do |rabbitmq_host|
|
16
|
-
puts "\tDisplay Name: #{rabbitmq_host["displayname"]}, host: #{rabbitmq_host["hostname"]}, username: #{rabbitmq_host["username"]}, enabled #{rabbitmq_host["enabled"]}"
|
17
|
-
end
|
18
|
-
|
19
|
-
# Initialize all enabled consumners
|
20
|
-
# NOTE: this method will be replaced with a routine to reflect through all valid consumers and initialze them implicitly
|
21
|
-
def initialize_consumers(rabbitmq_host)
|
22
|
-
puts "Initializing Consumers for #{rabbitmq_host["displayname"]}"
|
23
|
-
consumers = []
|
24
|
-
@config.consumers.each do |consumer|
|
25
|
-
if consumer["enabled"] == true
|
26
|
-
case consumer["name"]
|
27
|
-
when "console_consumer"
|
28
|
-
consumers << RabbitHutch::ConsoleConsumer.new()
|
29
|
-
when "mongo_consumer"
|
30
|
-
consumers << RabbitHutch::MongoConsumer.new(rabbitmq_host, @config)
|
31
|
-
when "log4r_consumer"
|
32
|
-
consumers << RabbitHutch::Log4rConsumer.new(rabbitmq_host, @config)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
consumers
|
37
|
-
end
|
38
|
-
|
39
|
-
# Start the worker process to listen to a RabbitMq Node
|
40
|
-
def start_worker(rabbitmq_host)
|
41
|
-
displayname = rabbitmq_host["displayname"]
|
42
|
-
hostname = rabbitmq_host["hostname"]
|
43
|
-
username = rabbitmq_host["username"]
|
44
|
-
password = rabbitmq_host["password"]
|
45
|
-
|
46
|
-
consumers = initialize_consumers(rabbitmq_host)
|
47
|
-
|
48
|
-
puts "\tListening to RabbitMq #{displayname}, host: #{hostname}, username #{username}"
|
49
|
-
AMQP.connect(:host => hostname, :user => username, :password => password) do |connection|
|
50
|
-
channel = AMQP::Channel.new(connection)
|
51
|
-
worker = RabbitHutch::Worker.new(channel, @config, consumers)
|
52
|
-
worker.start
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# Entry Point to the application, Begins queue listener and initializes all consmers
|
57
|
-
def start
|
58
|
-
begin
|
59
|
-
#initialize_consumers
|
60
|
-
|
61
|
-
EventMachine.run do
|
62
|
-
puts "Initializing RabbitMq Listener"
|
63
|
-
@config.rabbitmq_hosts.each do |rabbitmq_host|
|
64
|
-
if rabbitmq_host["enabled"] == true
|
65
|
-
start_worker(rabbitmq_host)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
Signal.trap("INT"){EventMachine.stop}
|
69
|
-
Signal.trap("QUIT"){EventMachine.stop}
|
70
|
-
Signal.trap("TERM"){EventMachine.stop}
|
71
|
-
Signal.trap("TSTP"){EventMachine.stop}
|
72
|
-
end
|
73
|
-
rescue Exception=>e
|
74
|
-
puts "#{e.message} #{e.backtrace}"
|
75
|
-
#@log.error("#{e.message} #{e.backtrace}")
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Kick off the App
|
80
|
-
start
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
+
@log = nil #RabbitHutch::MyLogger.init(@config)
|
11
|
+
|
12
|
+
puts "-------------------------"
|
13
|
+
puts "Starting RabbitHutch"
|
14
|
+
puts "\tEnvironment Settings"
|
15
|
+
@config.rabbitmq_hosts.each do |rabbitmq_host|
|
16
|
+
puts "\tDisplay Name: #{rabbitmq_host["displayname"]}, host: #{rabbitmq_host["hostname"]}, username: #{rabbitmq_host["username"]}, enabled #{rabbitmq_host["enabled"]}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Initialize all enabled consumners
|
20
|
+
# NOTE: this method will be replaced with a routine to reflect through all valid consumers and initialze them implicitly
|
21
|
+
def initialize_consumers(rabbitmq_host)
|
22
|
+
puts "Initializing Consumers for #{rabbitmq_host["displayname"]}"
|
23
|
+
consumers = []
|
24
|
+
@config.consumers.each do |consumer|
|
25
|
+
if consumer["enabled"] == true
|
26
|
+
case consumer["name"]
|
27
|
+
when "console_consumer"
|
28
|
+
consumers << RabbitHutch::ConsoleConsumer.new()
|
29
|
+
when "mongo_consumer"
|
30
|
+
consumers << RabbitHutch::MongoConsumer.new(rabbitmq_host, @config)
|
31
|
+
when "log4r_consumer"
|
32
|
+
consumers << RabbitHutch::Log4rConsumer.new(rabbitmq_host, @config)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
consumers
|
37
|
+
end
|
38
|
+
|
39
|
+
# Start the worker process to listen to a RabbitMq Node
|
40
|
+
def start_worker(rabbitmq_host)
|
41
|
+
displayname = rabbitmq_host["displayname"]
|
42
|
+
hostname = rabbitmq_host["hostname"]
|
43
|
+
username = rabbitmq_host["username"]
|
44
|
+
password = rabbitmq_host["password"]
|
45
|
+
|
46
|
+
consumers = initialize_consumers(rabbitmq_host)
|
47
|
+
|
48
|
+
puts "\tListening to RabbitMq #{displayname}, host: #{hostname}, username #{username}"
|
49
|
+
AMQP.connect(:host => hostname, :user => username, :password => password) do |connection|
|
50
|
+
channel = AMQP::Channel.new(connection)
|
51
|
+
worker = RabbitHutch::Worker.new(channel, @config, consumers)
|
52
|
+
worker.start
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Entry Point to the application, Begins queue listener and initializes all consmers
|
57
|
+
def start
|
58
|
+
begin
|
59
|
+
#initialize_consumers
|
60
|
+
|
61
|
+
EventMachine.run do
|
62
|
+
puts "Initializing RabbitMq Listener"
|
63
|
+
@config.rabbitmq_hosts.each do |rabbitmq_host|
|
64
|
+
if rabbitmq_host["enabled"] == true
|
65
|
+
start_worker(rabbitmq_host)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
Signal.trap("INT"){EventMachine.stop}
|
69
|
+
Signal.trap("QUIT"){EventMachine.stop}
|
70
|
+
Signal.trap("TERM"){EventMachine.stop}
|
71
|
+
Signal.trap("TSTP"){EventMachine.stop}
|
72
|
+
end
|
73
|
+
rescue Exception=>e
|
74
|
+
puts "#{e.message} #{e.backtrace}"
|
75
|
+
#@log.error("#{e.message} #{e.backtrace}")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Kick off the App
|
80
|
+
start
|
81
|
+
|
82
|
+
|
83
|
+
|
data/lib/worker.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
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
|
-
def start
|
20
|
-
@exchange = @channel.topic(@exchange_name, :durable => true, :auto_delete => false, :internal => true)
|
21
|
-
@queue = @channel.queue(@queue_name, :durable => false, :auto_delete => true)
|
22
|
-
@queue.bind(@exchange, :routing_key => '#')
|
23
|
-
@queue.subscribe(&@consumer.method(:handle_message))
|
24
|
-
end
|
25
|
-
|
26
|
-
def handle_channel_exception(channel, channel_close)
|
27
|
-
puts "Oops... a channel-level exception: code = #{channel_close.reply_code}, message = #{channel_close.reply_text}"
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
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
|
+
def start
|
20
|
+
@exchange = @channel.topic(@exchange_name, :durable => true, :auto_delete => false, :internal => true)
|
21
|
+
@queue = @channel.queue(@queue_name, :durable => false, :auto_delete => true)
|
22
|
+
@queue.bind(@exchange, :routing_key => '#')
|
23
|
+
@queue.subscribe(&@consumer.method(:handle_message))
|
24
|
+
end
|
25
|
+
|
26
|
+
def handle_channel_exception(channel, channel_close)
|
27
|
+
puts "Oops... a channel-level exception: code = #{channel_close.reply_code}, message = #{channel_close.reply_text}"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
32
|
end
|
data/rabbithutch.gemspec
CHANGED
@@ -1,35 +1,35 @@
|
|
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 = %q{rabbithutch}
|
7
|
-
gem.version = "0.0.
|
8
|
-
gem.authors = ["John Ryan"]
|
9
|
-
gem.email = ["555john@gmail.com"]
|
10
|
-
gem.description = %q{RabbitMq Trace Logger - Listen to multiple RabbitMq instances and log them to a
|
11
|
-
single location or MongoDb database. }
|
12
|
-
gem.summary = %q{A ruby service for monotoring the trace output on RabbitMq Nodes and writing the output to console, Log files or MongoDb}
|
13
|
-
gem.homepage = %q{http://github.com/jnyryan/}
|
14
|
-
|
15
|
-
gem.extra_rdoc_files = ["LICENSE.txt","README.md" ]
|
16
|
-
gem.files = `git ls-files`.split($/)
|
17
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
-
gem.executable = 'rabbithutch'
|
19
|
-
gem.require_paths = ["lib"]
|
20
|
-
|
21
|
-
gem.rdoc_options << '--exclude spec/testfiles'
|
22
|
-
|
23
|
-
gem.add_dependency "amqp"
|
24
|
-
gem.add_dependency "bson_ext"
|
25
|
-
gem.add_dependency "daemons"
|
26
|
-
gem.add_dependency "eventmachine"
|
27
|
-
gem.add_dependency "logger"
|
28
|
-
gem.add_dependency "log4r"
|
29
|
-
gem.add_dependency "mq"
|
30
|
-
gem.add_dependency "mongo"
|
31
|
-
gem.add_dependency "mongo_ext"
|
32
|
-
gem.add_dependency "thor"
|
33
|
-
gem.add_dependency "yard"
|
34
|
-
|
35
|
-
end
|
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 = %q{rabbithutch}
|
7
|
+
gem.version = "0.0.7"
|
8
|
+
gem.authors = ["John Ryan"]
|
9
|
+
gem.email = ["555john@gmail.com"]
|
10
|
+
gem.description = %q{RabbitMq Trace Logger - Listen to multiple RabbitMq instances and log them to a
|
11
|
+
single location or MongoDb database. }
|
12
|
+
gem.summary = %q{A ruby service for monotoring the trace output on RabbitMq Nodes and writing the output to console, Log files or MongoDb}
|
13
|
+
gem.homepage = %q{http://github.com/jnyryan/}
|
14
|
+
|
15
|
+
gem.extra_rdoc_files = ["LICENSE.txt","README.md" ]
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.executable = 'rabbithutch'
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.rdoc_options << '--exclude spec/testfiles'
|
22
|
+
|
23
|
+
gem.add_dependency "amqp"
|
24
|
+
gem.add_dependency "bson_ext"
|
25
|
+
gem.add_dependency "daemons"
|
26
|
+
gem.add_dependency "eventmachine"
|
27
|
+
gem.add_dependency "logger"
|
28
|
+
gem.add_dependency "log4r"
|
29
|
+
gem.add_dependency "mq"
|
30
|
+
gem.add_dependency "mongo"
|
31
|
+
gem.add_dependency "mongo_ext"
|
32
|
+
gem.add_dependency "thor"
|
33
|
+
gem.add_dependency "yard"
|
34
|
+
|
35
|
+
end
|
data/rabbithutchservice.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'daemons'
|
3
|
-
|
4
|
-
# The Service controller.
|
5
|
-
def start_service
|
6
|
-
begin
|
7
|
-
Daemons.run(File.dirname(__FILE__) + '/lib/rabbithutch.rb')
|
8
|
-
rescue SystemExit=>e
|
9
|
-
puts e.inspect
|
10
|
-
rescue Exception=>e
|
11
|
-
puts e.inspect
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
start_service()
|
16
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'daemons'
|
3
|
+
|
4
|
+
# The Service controller.
|
5
|
+
def start_service
|
6
|
+
begin
|
7
|
+
Daemons.run(File.dirname(__FILE__) + '/lib/rabbithutch.rb')
|
8
|
+
rescue SystemExit=>e
|
9
|
+
puts e.inspect
|
10
|
+
rescue Exception=>e
|
11
|
+
puts e.inspect
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
start_service()
|
16
|
+
|
data/rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
|
3
|
-
task :default
|
4
|
-
|
5
|
-
end
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
task :default
|
4
|
+
|
5
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbithutch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -210,7 +210,6 @@ files:
|
|
210
210
|
- lib/consumers/console_consumer.rb
|
211
211
|
- lib/consumers/log4r_consumer.rb
|
212
212
|
- lib/consumers/mongo_consumer.rb
|
213
|
-
- lib/logger.rb
|
214
213
|
- lib/rabbithutch.rb
|
215
214
|
- lib/worker.rb
|
216
215
|
- rabbithutch.gemspec
|
@@ -237,9 +236,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
236
|
version: '0'
|
238
237
|
requirements: []
|
239
238
|
rubyforge_project:
|
240
|
-
rubygems_version: 1.8.
|
239
|
+
rubygems_version: 1.8.24
|
241
240
|
signing_key:
|
242
241
|
specification_version: 3
|
243
242
|
summary: A ruby service for monotoring the trace output on RabbitMq Nodes and writing
|
244
243
|
the output to console, Log files or MongoDb
|
245
244
|
test_files: []
|
245
|
+
has_rdoc:
|
data/lib/logger.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'log4r'
|
2
|
-
require 'log4r/yamlconfigurator'
|
3
|
-
require 'log4r/outputter/syslogoutputter'
|
4
|
-
|
5
|
-
module RabbitHutch
|
6
|
-
class MyLogger
|
7
|
-
@@log = nil
|
8
|
-
def self.init(config)
|
9
|
-
if !@@log.nil?
|
10
|
-
return @@log
|
11
|
-
end
|
12
|
-
|
13
|
-
configurator = Log4r::YamlConfigurator
|
14
|
-
configurator.decode_yaml config.log_config
|
15
|
-
@@log = Log4r::Logger['main']
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|