Class: Vizcore::Server::GalleryRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/vizcore/server/gallery_runner.rb

Overview

Starts a small Rack/Puma server for the example gallery.

Constant Summary collapse

DEFAULT_PORT =
Config::DEFAULT_PORT + 1

Instance Method Summary collapse

Constructor Details

#initialize(host: Config::DEFAULT_HOST, port: DEFAULT_PORT, output: $stdout) ⇒ GalleryRunner

Returns a new instance of GalleryRunner.

Parameters:

  • host (String) (defaults to: Config::DEFAULT_HOST)
  • port (Integer) (defaults to: DEFAULT_PORT)
  • output (#puts) (defaults to: $stdout)


16
17
18
19
20
# File 'lib/vizcore/server/gallery_runner.rb', line 16

def initialize(host: Config::DEFAULT_HOST, port: DEFAULT_PORT, output: $stdout)
  @host = host
  @port = Integer(port)
  @output = output
end

Instance Method Details

#runvoid

This method returns an undefined value.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vizcore/server/gallery_runner.rb', line 23

def run
  server = Puma::Server.new(GalleryApp.new, nil, min_threads: 0, max_threads: 4)
  server.add_tcp_listener(@host, @port)
  server.run

  @output.puts("Vizcore gallery: http://#{@host}:#{@port}")
  @output.puts("Press Ctrl+C to stop.")
  wait_for_interrupt
ensure
  server&.stop(true)
end