server

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package server implements the live-reloading development server for kwelea.

The entry point is Start, which:

  1. Runs an initial builder.Build to populate the output directory.
  2. Binds to the configured port (auto-incrementing up to +10 if occupied).
  3. Starts a Hub goroutine that broadcasts WebSocket reload signals to all connected browser tabs.
  4. Starts an fsnotify watcher over the docs directory and kwelea.toml; on any change it rebuilds and calls Hub.Reload.
  5. Serves the output directory over HTTP and handles WebSocket upgrades at /_kwelea/ws.
  6. Optionally opens the browser at the resolved URL.

The server shuts down cleanly on SIGTERM or SIGINT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(cfg *config.Config, embFS fs.FS, cfgPath string) error

Start is the entry point for `kwelea serve`. It:

  1. Runs an initial build in devMode
  2. Resolves an available port (base..base+10)
  3. Starts the WebSocket hub and file watcher
  4. Serves the output directory as a static site
  5. Opens the browser (unless disabled)
  6. Blocks until SIGINT/SIGTERM, then shuts down cleanly

Types

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

Hub tracks all connected WebSocket clients and fans out reload signals to them. It runs as a single goroutine (via hub.run) so the client map needs no mutex.

func (*Hub) Reload

func (h *Hub) Reload()

Reload broadcasts a reload signal to every connected client. Non-blocking: if a previous signal hasn't been consumed it's coalesced.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL