Class: Sorta::Http::Server
- Inherits:
-
Object
- Object
- Sorta::Http::Server
- Defined in:
- lib/sorta/http/server.rb
Constant Summary collapse
- CPU_COUNT =
Etc.nprocessors
Instance Method Summary collapse
-
#initialize(app, **options) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
Constructor Details
#initialize(app, **options) ⇒ Server
Returns a new instance of Server.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sorta/http/server.rb', line 14 def initialize(app, **) @app = app = @cpu_count = [:workers] || CPU_COUNT @port = [:port] || 8080 @host = [:host] || 'localhost' @logger = [:logger] || Logger.new init_pipe init_workers # TODO: init_supervisor end |
Instance Method Details
#run ⇒ Object
27 28 29 30 |
# File 'lib/sorta/http/server.rb', line 27 def run tcp_server = TCPServer.new(@host, @port) loop { @pipe.send(tcp_server.accept, move: true) } end |