Class: Wytch::Server
- Inherits:
-
Object
- Object
- Wytch::Server
- Defined in:
- lib/wytch/server.rb
Overview
Development server for Wytch sites.
The Server provides a local development environment with:
- Hot reloading of site code and content
- Static file serving from public/
- Page rendering on each request
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Server options (port, host).
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Server
constructor
Creates a new server instance.
-
#start ⇒ void
Starts the development server.
Constructor Details
#initialize(options = {}) ⇒ Server
Creates a new server instance.
28 29 30 |
# File 'lib/wytch/server.rb', line 28 def initialize( = {}) = end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns server options (port, host).
21 22 23 |
# File 'lib/wytch/server.rb', line 21 def end |
Instance Method Details
#start ⇒ void
This method returns an undefined value.
Starts the development server.
Loads the site configuration, starts file watchers for hot reloading, and begins serving requests. This method blocks until the server is stopped.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/wytch/server.rb', line 38 def start ENV["RACK_ENV"] = "development" Site.load! require "puma" require "puma/server" port = [:port] || 6969 host = [:host] || "localhost" puts "Starting Wytch development server on http://#{host}:#{port}" puts "Press Ctrl+C to stop" server = Puma::Server.new(app) server.add_tcp_listener(host, port) server.run.join end |