Sha256: 989f59cb60a5001742c378c85332f85e232badbda5f0a5c9ef39191b04ad8228
Contents?: true
Size: 870 Bytes
Versions: 11
Compression:
Stored size: 870 Bytes
Contents
require "rack" module Sitepress # 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. class PreviewServer DEFAULT_PORT = 8080 DEFAULT_BIND_ADDRESS = "0.0.0.0".freeze def initialize(project:) @project = project end 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 private def rack_app Proc.new { |env| @project.server.call(env) } end end end
Version data entries
11 entries across 11 versions & 1 rubygems