Skip to content

Commit

Permalink
Restructure option handling from config file, explicitly support new …
Browse files Browse the repository at this point in the history
…options, until now a user could have set any value in the options hash he wanted through the config file
  • Loading branch information
tak1n committed Feb 19, 2016
1 parent 33cbc6b commit 5b9241b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/reifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ module Reifier
POST = 'POST'.freeze
PUT = 'PUT'.freeze

HTTPParseError = Class.new(StandardError)
HTTPParseError = Class.new(StandardError)
UnsupportedOptionError = Class.new(StandardError)
ERROR_HEADER = '=============================== FATAL SERVER ERROR =============================='.freeze
ERROR_FOOTER = "=================================================================================\n\n\n".freeze
end
16 changes: 12 additions & 4 deletions lib/reifier/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ def load_configuration
lines = File.read(path).split("\n")

lines.each do |line|
option = line.split.first.capitalize
value = line.split.last

@options[option.to_sym] = value
eval(line)
end

puts "======= Loaded settings from #{path} =======\n"
rescue NoMethodError => e
raise UnsupportedOptionError, "Option #{e.name} is not supported from config file"
end

def start
Expand Down Expand Up @@ -64,6 +63,15 @@ def start

private

def threads(min, max)
@options[:MinThreads] = min
@options[:MaxThreads] = max
end

def workers(count)
@options[:Workers] = count
end

def spawn_worker(server)
fork do
pool = Concurrent::ThreadPoolExecutor.new(
Expand Down

0 comments on commit 5b9241b

Please sign in to comment.