Class: Traut::Application
- Inherits:
-
Object
- Object
- Traut::Application
- Defined in:
- lib/traut/application.rb
Instance Method Summary collapse
-
#initialize(params) ⇒ Application
constructor
A new instance of Application.
-
#run ⇒ Object
Parse the arguments and run the program.
Constructor Details
#initialize(params) ⇒ Application
Returns a new instance of Application.
7 8 9 |
# File 'lib/traut/application.rb', line 7 def initialize(params) @options = params[:options] || raise('parameter :options required') end |
Instance Method Details
#run ⇒ Object
Parse the arguments and run the program. Exit on error.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/traut/application.rb', line 12 def run @logger = Logger.new File.join( File.(@options['logdir']), 'traut.log') @logger.level = boolean(@options['debug']) ? Logger::DEBUG : Logger::INFO ## NOTE: Have to start AMQP connection out here. amqp = @options['amqp'] AMQP.connect(:host => amqp['host'], :port => amqp['port'], :vhost => amqp['vhost'], :username => amqp['username'], :password => amqp['password']) do |connection| @logger.info "Traut #{Traut::VERSION} started" channel = AMQP::Channel.new(connection) exchange = channel.topic(amqp['exchange'] || 'traut') Traut::Server.new(:channel => channel, :exchange => exchange, :events => @options['events'], :log => @logger).run end end |