diff --git a/lib/activemessaging/gateway.rb b/lib/activemessaging/gateway.rb index e7059f6..3411099 100644 --- a/lib/activemessaging/gateway.rb +++ b/lib/activemessaging/gateway.rb @@ -342,24 +342,20 @@ def processor_group group_name, *processors end def current_processor_group - if ARGV.length > 0 && !@current_processor_group - ARGV.each {|arg| - pair = arg.split('=') - if pair[0] == 'process-group' - group_sym = pair[1].to_sym - if processor_groups.has_key? group_sym - @current_processor_group = group_sym - else - ActiveMessaging.logger.error "Unrecognized process-group." - ActiveMessaging.logger.error "You specified process-group #{pair[1]}, make sure this is specified in config/messaging.rb" - ActiveMessaging.logger.error " ActiveMessaging::Gateway.define do |s|" - ActiveMessaging.logger.error " s.processor_groups = { :group1 => [:foo_bar1_processor], :group2 => [:foo_bar2_processor] }" - ActiveMessaging.logger.error " end" - exit - end - end - } + if ENV['PROCESS_GROUP'].present? && !@current_processor_group + group_sym = ENV['PROCESS_GROUP'].to_sym + if processor_groups.has_key? group_sym + @current_processor_group = group_sym + else + ActiveMessaging.logger.error "Unrecognized process-group." + ActiveMessaging.logger.error "You specified process-group #{pair[1]}, make sure this is specified in config/messaging.rb" + ActiveMessaging.logger.error " ActiveMessaging::Gateway.define do |s|" + ActiveMessaging.logger.error " s.processor_groups = { :group1 => [:foo_bar1_processor], :group2 => [:foo_bar2_processor] }" + ActiveMessaging.logger.error " end" + exit + end end + @current_processor_group end diff --git a/lib/tasks/start_consumers.rake b/lib/tasks/start_consumers.rake index 5ec1946..054b129 100644 --- a/lib/tasks/start_consumers.rake +++ b/lib/tasks/start_consumers.rake @@ -2,7 +2,7 @@ namespace "activemessaging" do desc 'Run all consumers' task :start_consumers do - load File.dirname(__FILE__) + '/../poller.rb' + load File.join(File.dirname(__FILE__), '..', '..', 'poller.rb') end -end \ No newline at end of file +end diff --git a/poller.rb b/poller.rb index f11fac6..59c326e 100644 --- a/poller.rb +++ b/poller.rb @@ -3,12 +3,7 @@ STDOUT.sync = true; STDOUT.flush STDERR.sync = true; STDERR.flush -# Load Rails -RAILS_ROOT=File.expand_path(File.join(File.dirname(__FILE__), '..','..','..')) -load File.join(RAILS_ROOT, 'config', 'environment.rb') - -# Load ActiveMessaging processors -#ActiveMessaging::load_processors +load File.join(Rails.root, 'config', 'environment.rb') # Start it up! ActiveMessaging::start