Skip to content
This repository was archived by the owner on Jan 10, 2019. It is now read-only.
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
11 changes: 9 additions & 2 deletions aws-flow/lib/aws/decider/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ class LogFactory
def self.make_logger(klass)
make_logger_with_level(klass, Logger::INFO)
end

def self.make_logger_with_level(klass, level)
logname = "#{Dir.tmpdir}/#{klass.class.to_s}"
logname.gsub!(/::/, '-')
log = Logger.new(logname)
log.level = level
create_logger_from_configuration_hash({:path => logname, :level => level})
end

def self.create_logger_from_configuration_hash(options)
raise "Logger option should be a hash" unless options.is_a? Hash
log = Logger.new(options[:path])
log.level = options[:level]
log
end

end

def self.workflow_task_to_debug_string(message, task, task_list)
Expand Down
3 changes: 2 additions & 1 deletion aws-flow/lib/aws/decider/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
module AWS
module Flow
def self.version
"3.1.0"
"3.1.1"
end
end
end

24 changes: 20 additions & 4 deletions aws-flow/lib/aws/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def self.start_activity_workers(swf, domain = nil, json_config)
# is defaulted to 0.
number_of_default_workers = 0

# TODO: logger
# start the workers for each spec
if json_config['activity_workers']
json_config['activity_workers'].each do |w|
Expand All @@ -198,8 +197,17 @@ def self.start_activity_workers(swf, domain = nil, json_config)
# task_list for this worker
task_list ||= "#{classes.first}"

#worker options
options = { execution_workers: fork_count }

#init logger if needed
if w['logger']
logger = Utilities::LogFactory.create_logger_from_configuration_hash(w['logger'])
options[:logger] = logger
end

# Create a worker
worker = ActivityWorker.new(swf.client, domain, task_list) {{ execution_workers: fork_count }}
worker = ActivityWorker.new(swf.client, domain, task_list) {options}

classes.each do |c|
c = AWS::Flow::Templates.make_activity_class(c) unless c.is_a?(AWS::Flow::Activities)
Expand Down Expand Up @@ -264,7 +272,6 @@ def self.start_workflow_workers(swf, domain = nil, json_config)
workers = []
domain = setup_domain(json_config) if domain.nil?

# TODO: logger
# start the workers for each spec
if json_config['workflow_workers']
json_config['workflow_workers'].each do |w|
Expand All @@ -274,8 +281,17 @@ def self.start_workflow_workers(swf, domain = nil, json_config)
classes = get_classes(w, {config_key: 'workflow_classes',
clazz: AWS::Flow::Workflows})

#worker options
options = {}

#init logger if needed
if w['logger']
logger = Utilities::LogFactory.create_logger_from_configuration_hash(w['logger'])
options[:logger] = logger
end

# Create a worker
worker = WorkflowWorker.new(swf.client, domain, task_list, *classes)
worker = WorkflowWorker.new(swf.client, domain, task_list, *classes) { options }

# Start as many workers as desired in child processes
workers << spawn_and_start_workers(w, "workflow-worker", worker)
Expand Down