Class: Sitepress::PreviewServer

Inherits:
Object
  • Object
show all
Defined in:
lib/sitepress/preview_server.rb

Overview

Evaluates a configuration file on each site request, then delegates to a sitepres server for rednering. In a production environment, you'd want to run `Sitepress::Server` directly.

Constant Summary collapse

DEFAULT_PORT =
8080
DEFAULT_BIND_ADDRESS =
"0.0.0.0".freeze

Instance Method Summary collapse

Constructor Details

#initialize(project:) ⇒ PreviewServer

Returns a new instance of PreviewServer.


11
12
13
# File 'lib/sitepress/preview_server.rb', line 11

def initialize(project:)
  @project = project
end

Instance Method Details

#run(port: DEFAULT_PORT, bind_address: DEFAULT_BIND_ADDRESS) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sitepress/preview_server.rb', line 15

def run(port: DEFAULT_PORT, bind_address: DEFAULT_BIND_ADDRESS)
  # TODO: Move all of this junk into the PreviewServer class. Move
  # what's in there now into PreviewServer::Rack
  Rack::Handler::WEBrick.run rack_app,
    BindAddress: bind_address,
    Port: port do |server|
      Signal.trap "SIGINT" do
        server.stop
      end
  end
end