Changelog¶
All notable changes to litestar-granian are documented in this file.
0.17.0¶
Added¶
- Added
--access-log/--no-access-logand--access-log-fmtCLI aliases for--granian-access-log/--granian-no-access-logand--granian-access-log-fmt(#82).
Changed¶
- Dropped Python 3.10 support (
requires-python = ">=3.11") and added Python 3.15 and 3.15t (free-threaded) support and CI coverage (#82). - Updated minimum Granian requirement to
granian[all]>=2.8.5(and therloop,uvloop, andwinloopextras to>=2.8.5), adopting Granian 2.8's per-workerSO_REUSEPORTTCP listener sockets on Linux,%(header{...})saccess log format atoms, and upstream free-threaded Python (3.14t) lifecycle fixes (#82). - Updated
--backlogCLI help text and configuration guidance to reflect Granian 2.8's per-socket backlog semantics and documented--backpressuresizing relative to per-worker database connection pools (#82). - Retained
--in-subprocess/--no-subprocessand--use-litestar-logger/--no-litestar-loggeras deprecated no-op compatibility switches for0.17.0, planned for removal in0.18(#82). - Added
slots=Trueto_GranianCommandand_StaticMounts(#82). - Migrated documentation to Zensical with
mkdocstrings-python, automated CLI reference generation,llms.txt/llms-full.txtartifacts, and HTML verification gates (#82). - Bumped
actions/checkouttov7.0.1,actions/setup-pythontov6.2.0,actions/upload-pages-artifacttov5,actions/deploy-pagestov5,astral-sh/setup-uvtov10.3.2, andpypa/gh-action-pypi-publishtov1.14.3across GitHub Actions workflows (#82, #84, #85).
Fixed¶
- Promoted the free-threaded Python (
3.14t) repeated metrics lifecycle (emmett-framework/granian#881) and WebSocket teardown (emmett-framework/granian#884) diagnostics to standard integration regressions now that both upstream defects are fixed in Granian 2.8.5 (#82).
0.16.0¶
Modified Behavior¶
litestar runnow has one execution model: the Litestar parent enters server lifespans once and supervises a fresh Granian child process group.--in-subprocess/--no-subprocessand--use-litestar-logger/--no-litestar-loggerremain as deprecated no-op compatibility switches for0.16. Supervision and automatic formatter matching remain unconditional.- Restored Litestar's
-I/--reload-includeand-E/--reload-excludeglob behavior. Reload directories and filters now enable reload automatically, matchinglitestar run. - Added Litestar-compatible
-F/--fd/--file-descriptorinherited socket support on POSIX. - Added Litestar-compatible
-Uand--unix-domain-socketaliases for Granian's retained native--udsoption. --pdb/--use-pdbandLITESTAR_PDB=truenow propagate Litestar'spdb_on_exceptionbehavior into Granian workers.- Granian metrics are explicit and disabled by default. When
--metricsis used without Litestar Prometheus middleware, the command warns that only Granian server and worker metrics will be exported. - The deprecated
InitPluginProtocolbase is replaced byInitPlugin.
Supervisor and Lifespans¶
- POSIX starts Granian in a new session and forwards signals to the process group. Windows uses a new process group,
CTRL_BREAK_EVENTfor graceful shutdown, and list-basedtaskkillonly after escalation. - The first termination signal is forwarded once and starts a deadline equal to
--workers-kill-timeoutplus five seconds. A second signal or expired deadline kills the Granian process group. - Litestar's server lifespans remain active until Granian exits and are still unwound after forced termination.
- The resolved application path, bind host, and bind port are available to server-lifespan sidecars as
LITESTAR_APP,LITESTAR_HOST, andLITESTAR_PORT, and previous environment values are restored afterward. - Granian's exact child status is returned; signal exits use
128 + signal.
Logging¶
- Granian now matches Litestar's active compatible formatter automatically. Direct handlers, queue-listener output handlers, propagation/root handlers, and structurally compatible configuration fallback are supported without classifying the formatter as standard, JSON, or
structlog. - Formatter presentation is no longer a plugin mode or built-in schema. Optional
structlogand JSON packages remain application choices and are not production dependencies of this plugin. - Generated configurations deep-copy Granian's native logging configuration and replace only its
genericandaccessformatters. Parent handlers, queues, listeners, locks, loggers, and levels are never transplanted or mutated. - One mode-
0600generated file remains available for the complete supervised lifetime so worker reload and respawn reuse the same formatter payload. It is removed idempotently after normal exit, startup failure, signal termination, or lifespan failure. - If no compatible formatter exists, Granian retains native formatting. If a selected formatter cannot be reconstructed, startup fails before serving with actionable
--log-configguidance instead of silently changing presentation. - Explicit
--log-configbypasses matching and wins completely.
Granian 2.7.9 Parity¶
- The plugin continues to own Litestar's
runcommand surface and translates it to Granian. Litestar aliases are retained where their semantics match, Granian-native option spellings remain available, and both environment namespaces are accepted for equivalent settings with explicitLITESTAR_*precedence. - CLI help presents every standard Litestar
runoption first, in Litestar's order, followed by Granian-specific extensions and then the deprecated compatibility shims. - Removed the CPU-derived worker ceiling;
--workersvalidates only a minimum of one. - HTTP mode forwarding is protocol-aware.
autoreceives HTTP/1 and HTTP/2 settings, HTTP/1 receives only HTTP/1 settings, and HTTP/2 receives only HTTP/2 settings with WebSockets disabled. - Updated every HTTP/2 numeric range to Granian 2.7.9.
--ssl-client-verifyrequires--ssl-ca.- Minimum dependencies updated to
litestar>=2.19.0andgranian[all]>=2.7.9.rloop,uvloop, andwinloopextras are delegated through Granian; redundant directhttptoolsandwebsocketsdependencies are removed.
Static Serving¶
- Added
GranianPlugin(static="auto")as a structural consumer of one plugin exposingget_static_server_config(). - Discovery validates local absolute routes, existing non-empty directories, consistent directory-index values, and explicit fallback reasons.
- Missing, multiple, malformed, or ineligible providers produce one
INFOfallback and leave serving to Litestar. Explicit CLI mounts always win.
Documentation and Release Repair¶
- Replaced the stale direct/subprocess guide with beginner-first process, signal, logging, deployment, native-option, and migration documentation.
- Replaced the custom multiversion Pages builder with the official configure/upload/deploy actions and one current site artifact.
- Corrected project URLs to
https://cofin.github.io/litestar-granian/and removedlatest/assumptions.
Known Upstream Limitations (2.7.9)¶
- Granian's open shutdown defect tracked in emmett-framework/granian#875.
- Granian 2.7.9 rejects reload on free-threaded Python.
- Granian metrics remain explicit because of the shutdown panic in emmett-framework/granian#881.
- The PyO3 pointer panic tracked in emmett-framework/granian#884.
0.15.0¶
Breaking Changes¶
--runtime-modedefault changed fromsingle(st) toauto. Pass--runtime-mode stexplicitly if you relied on the old default.--static-path-routeand--static-path-mountare repeatable for multi-mount serving. The previous implicit/staticdefault has been removed.--static-path-expirestype changed fromIntRange(min=60)toDuration(0).0disables caching; human-readable values like1dand1hare accepted.- Duration type migrations:
--blocking-threads-idle-timeout,--workers-kill-timeout, and--http2-keep-alive-timeoutaccept human-readable durations in addition to integer seconds. - Minimum
granianbumped to>=2.7.0. - Python 3.9 support dropped; Python 3.14 and 3.14t (free-threaded) added to the test matrix.
Migration Notes¶
_granianandgranian.accessloggers are no longer overwritten when defined in userLoggingConfig.granian.log.LOGGING_CONFIGis no longer mutated across invocations.- Added
--working-dir,--env-files,--log-config,--static-path-dir-to-file,--metrics,--metrics-scrape-interval,--metrics-address,--metrics-port,--reload-include,--reload-exclude, and--ssl-certfile. - Fixed
--pid-filepath serialization and--respawn-failed-workerssubprocess forwarding.