rabbithutch 0.1.4 → 0.1.5

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.
@@ -1,78 +1,78 @@
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
-
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
+
@@ -1,48 +1,48 @@
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()
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
48
  end
@@ -1,33 +1,33 @@
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
-
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
33
  end
@@ -1,37 +1,43 @@
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.1.4"
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://rabbithutch.herokuapp.com/}
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', 'bin/rabbithutch']
19
- gem.executables = ['rabbithutch', 'rabbithutchmgr']
20
- gem.require_paths = ["lib"]
21
-
22
- gem.rdoc_options << '--exclude spec/testfiles'
23
-
24
- gem.add_dependency "amqp"
25
- gem.add_dependency "bson_ext"
26
- gem.add_dependency "daemons"
27
- gem.add_dependency "eventmachine"
28
- gem.add_dependency "logger"
29
- gem.add_dependency "log4r"
30
- gem.add_dependency "mustache"
31
- gem.add_dependency "mq"
32
- gem.add_dependency "mongo"
33
- gem.add_dependency "mongo_ext"
34
- gem.add_dependency "thor"
35
- gem.add_dependency "yard"
36
-
37
- 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.1.5"
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
+ Also provides a web interface to manage the service}
14
+ gem.homepage = %q{http://rabbithutch.herokuapp.com/}
15
+
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
@@ -1,18 +1,18 @@
1
- require 'rubygems'
2
- require 'daemons'
3
-
4
- # The Service controller.
5
- def start_service
6
- begin
7
- puts "-------------------------"
8
- puts "Starting RabbitHutch"
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
-
1
+ require 'rubygems'
2
+ require 'daemons'
3
+
4
+ # The Service controller.
5
+ def start_service
6
+ begin
7
+ puts "-------------------------"
8
+ puts "Starting RabbitHutch"
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
+
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