Sha256: 18abc81360063bb072d1790931f7fa927d8f40deffed06a9079c3008dce91250

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

#!/usr/bin/env ruby

require "bundler/setup"
require "jflow"
require "slop"

opts = Slop.parse do |o|
  o.string '-f', '--file', 'worker configuration file'
end

configuration = JSON.parse(File.read(opts[:file]))

configuration_validator = {
  "number_of_workers" => "integer",
  "domain"            => "string",
  "tasklist"          => "string",
  "activities_path"   => "array"
}

validator = HashValidator.validate(configuration, configuration_validator)
raise "configuration is invalid! #{validator.errors}" unless validator.valid?

JFlow.configure do |c|
  c.load_paths = configuration["activities_path"]
end

JFlow.load_activities

threads = []

configuration["number_of_workers"].times do |i|
  threads << Thread.new do
    domain   = configuration["domain"]
    tasklist = configuration["tasklist"]
    JFlow::ActivityWorker.new(domain, tasklist)
                         .start!
  end
end

threads.each { |thr| thr.join }


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jflow-0.1.0 bin/jflow_worker