Class: Bundler::Spinel::Server
- Inherits:
-
Object
- Object
- Bundler::Spinel::Server
- Defined in:
- lib/bundler/spinel/server.rb
Overview
One process serving both halves of spinelgems.org — the apex double-duty layout as a single running app:
- the static human site (index.html, catalog.html, assets) via DocumentRoot
- when a store of vetted .gem files is given, the machine Compact Index
(/versions, /names, /info/<gem>, /gems/<file>.gem) mounted over the top
This is what the deploy host (Upsun) runs on $PORT. The Compact Index paths don’t collide with the human paths, so ‘source “spinelgems.org”` resolves against the curated source while a browser gets the site. The dogfood target is to replace this WEBrick host with a Spinel-compiled Tep app serving the same endpoints (see ARCHITECTURE.md §Dogfooding).
Instance Method Summary collapse
-
#initialize(public_dir:, store: nil, ledger: Ledger.new, engine: Engine.new, min_verdict: :verified) ⇒ Server
constructor
A new instance of Server.
- #run(port:, host: "0.0.0.0", quiet: true) ⇒ Object
Constructor Details
#initialize(public_dir:, store: nil, ledger: Ledger.new, engine: Engine.new, min_verdict: :verified) ⇒ Server
Returns a new instance of Server.
18 19 20 21 22 23 24 25 |
# File 'lib/bundler/spinel/server.rb', line 18 def initialize(public_dir:, store: nil, ledger: Ledger.new, engine: Engine.new, min_verdict: :verified) @public_dir = public_dir @store = store @ledger = ledger @engine = engine @min_verdict = min_verdict end |
Instance Method Details
#run(port:, host: "0.0.0.0", quiet: true) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bundler/spinel/server.rb', line 27 def run(port:, host: "0.0.0.0", quiet: true) server = WEBrick::HTTPServer.new( BindAddress: host, Port: port, DocumentRoot: @public_dir, Logger: WEBrick::Log.new(quiet ? File::NULL : $stderr), AccessLog: [] ) mount_index(server) %w[INT TERM].each { |sig| trap(sig) { server.shutdown } } warn "[spinelgems] serving #{@public_dir} on #{host}:#{port}" \ "#{@store ? " + Compact Index from #{@store}" : ' (no --store: site only)'}" server.start end |