Sha256: be15e3c6be617eacc8471e8fdceafbf0760b91937db5880c5558775dbc008a66

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony/http'

opts = {
  reuse_addr: true,
  dont_linger: true,
}

server = Polyphony::HTTP::Server.listen('0.0.0.0', 1234, opts)

puts "Listening on port 1234"

child_pids = []
4.times do
  child_pids << Polyphony.fork do
    puts "forked pid: #{Process.pid}"
    server.each do |req|
      req.respond("Hello world! from pid: #{Process.pid}\n")
    end
  rescue Interrupt
  end
end

child_pids.each { |pid| EV::Child.new(pid).await }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polyphony-0.19 examples/http/http_server_forked.rb