How joewalnes/websocketd works
websocketd wraps command-line programs as WebSocket services. Its main workflow is: an operator configures and starts the server; a client connects; the server maps the request to a process, exposes request details through CGI environment variables, and relays messages between WebSocket frames and the process’s standard streams. Separate capabilities include static-file and classic CGI serving, Unix sockets, and the developer console. The README documents the overall workflow; sampled code clarifies configuration, request handling, environment construction, and stream relay, but not every internal dispatch.
Main entry points: handler.go WebSocket Handler · http.go HTTP Server · main.go Server Runtime · config.go CLI Configuration
Components 16
Startup and Configuration
- CLI Configuration
config.go - Flag Definitions
internal/cliflags/cliflags.go - Server Runtime
main.go
HTTP Serving
- HTTP Server
libwebsocketd/http.go - Static Files
libwebsocketd/http.go - Classic CGI
libwebsocketd/http.go - Developer Console
libwebsocketd/console.go
WebSocket Sessions
- WebSocket Handler
libwebsocketd/handler.go - Endpoint Mapping
libwebsocketd/handler.go - CGI Environment
libwebsocketd/env.go - WebSocket Endpoint
libwebsocketd/websocket_endpoint.go
Process Integration
- Process Launcher
libwebsocketd/launcher.go - Process Endpoint
libwebsocketd/process_endpoint.go
Other components
- Operator
- WebSocket Client
- Command Process
Connections 18
- Operator → CLI Configuration: sets options
README.md - CLI Configuration → Flag Definitions: registers flags
config.go - Operator → Server Runtime: starts server
README.md - Server Runtime → CLI Configuration: parses options
main.go - Server Runtime → HTTP Server: serves requests
README.md - WebSocket Client → HTTP Server: connects
README.md - HTTP Server → WebSocket Handler: routes upgrades
- HTTP Server → Static Files: serves files
README.md - HTTP Server → Classic CGI: serves scripts
README.md - HTTP Server → Developer Console: serves console
README.md - WebSocket Handler → Endpoint Mapping: maps request
libwebsocketd/handler.go - WebSocket Handler → CGI Environment: builds variables
libwebsocketd/env.go - WebSocket Handler → WebSocket Endpoint: handles session
- WebSocket Handler → Process Launcher: starts process
README.md - Process Launcher → Command Process: launches
README.md - WebSocket Handler → Process Endpoint: relays session
- WebSocket Client → Process Endpoint: sends frames
README.md - Process Endpoint → Command Process: pipes stdin/stdout
README.md