Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poller.rb via Rake #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions lib/activemessaging/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/start_consumers.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
end
7 changes: 1 addition & 6 deletions poller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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