Class: DummyOscar::Server
- Inherits:
-
Object
- Object
- DummyOscar::Server
- Defined in:
- lib/dummy_oscar/server.rb
Constant Summary collapse
- DEFAULT_PORT =
8282
Instance Method Summary collapse
-
#initialize(config_file:, port: nil, library: nil) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(config_file:, port: nil, library: nil) ⇒ Server
Returns a new instance of Server.
9 10 11 12 |
# File 'lib/dummy_oscar/server.rb', line 9 def initialize(config_file:, port: nil, library: nil) @port = port || DEFAULT_PORT @app_builder = DummyOscar::App.build(config_file, library: library) end |
Instance Method Details
#start ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/dummy_oscar/server.rb', line 14 def start conf = Puma::Configuration.new do |user_config| user_config.threads(1, 4) user_config.port(@port) user_config.app { |env| @app_builder.app(env) } end $stdout.puts("Listening on http://localhost:#{@port}") Puma::Launcher.new(conf, log_writer: Puma::LogWriter.null).run end |