serve command starts the workerd server and serves requests based on the provided configuration.
Usage
Arguments
Path to the configuration file. Can be:
- A Cap’n Proto text file (
.capnp) - A binary Cap’n Proto file (with
--binaryflag) -to read from stdin (requires--binary)
Name of the Config constant to use from the config file. Required if the file defines multiple Config constants.For nested constants, use dot notation:
parentScope.constantNameOptions
Configuration parsing
Add a directory to the list of directories searched for non-relative imports (imports starting with
/).Can be specified multiple times.Indicates that the configuration file is an encoded binary Cap’n Proto message rather than text format.Useful when driving workerd from higher-level tooling that generates binary configs.
Socket configuration
Override the socket named
<name> to bind to the address <addr> instead of the address specified in the config file.Override the socket named
<name> to listen on the already-open file descriptor <fd> instead of the address specified in the config file.Service overrides
Override the directory named
<name> to point to <path> instead of the path specified in the config file.Override the external service named
<name> to connect to the address <addr> instead of the address specified in the config file.Development features
Watch configuration files and the server binary. Automatically reload when changes are detected.Useful for development, but not recommended in production.
Enable the Chrome DevTools inspector protocol on the specified address.
Enable sending control messages on the specified file descriptor. Currently reports the port each socket is listening on when ready.
Listen on the specified address for debug RPC connections. Exposes a privileged interface allowing access to all services in the process.For use by Miniflare and local development only.
Python support
Use the specified path as a disk cache to avoid repeatedly fetching Python packages from the internet.
Use the specified path as a disk cache to avoid repeatedly fetching Pyodide bundles from the internet.
Save a dedicated snapshot to the disk cache.
Save a baseline snapshot to the disk cache.
Load a snapshot from the Python snapshot directory.
Set the Python snapshot directory.
Advanced options
Permit the use of experimental features which may break backwards compatibility in a future release.
Enable Perfetto tracing output to the specified file with the given trace categories.Only available if workerd was built with Perfetto support.
Examples
Basic usage
Development workflow
Binary configuration
Multiple overrides
Signal handling
The server responds to signals:- SIGTERM: Gracefully drain connections and shut down
- SIGINT (Ctrl+C): Immediate shutdown
Exit codes
- 0: Successful execution
- 1: Configuration error or runtime error
- Other: System-specific error codes