Skip to content

Commit

Permalink
fix Future.new which requires a block, comment out signal handling in…
Browse files Browse the repository at this point in the history
… worker processes for now
  • Loading branch information
tak1n committed Feb 19, 2016
1 parent fdc654a commit 33cbc6b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/reifier/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,25 @@ def start
def spawn_worker(server)
fork do
pool = Concurrent::ThreadPoolExecutor.new(
# min_threads: [2, Concurrent.processor_count].max,
# max_threads: [2, Concurrent.processor_count].max,
# max_queue: [2, Concurrent.processor_count].max * 5,
min_threads: @options[:MinThreads],
max_threads: @options[:MaxThreads],
max_queue: 0,
fallback_policy: :caller_runs
fallback_policy: :caller_runs,
)

# Signal.trap 'SIGINT' do
# puts "Shutting down thread pool in Worker: #{Process.pid}"
# pool.shutdown
# pool.wait_for_termination

# exit
# end

loop do
socket = server.accept
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)

Concurrent::Future.new(executor: pool).execute do
Concurrent::Future.new(executor: pool) do
begin
request = Request.new(socket, @options)
response = Response.new(socket)
Expand All @@ -101,7 +106,7 @@ def spawn_worker(server)
STDERR.puts e.backtrace
STDERR.puts ERROR_FOOTER
end
end
end.execute
end
end
end
Expand Down

0 comments on commit 33cbc6b

Please sign in to comment.