diff --git a/lib/reifier.rb b/lib/reifier.rb index 2c0b0f1..e8727f4 100644 --- a/lib/reifier.rb +++ b/lib/reifier.rb @@ -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 diff --git a/lib/reifier/server.rb b/lib/reifier/server.rb index 51b36a6..9ecd1ac 100644 --- a/lib/reifier/server.rb +++ b/lib/reifier/server.rb @@ -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 @@ -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(